InputBox: handle mobile keyboard events

This commit is contained in:
He4eT 2021-07-23 14:38:43 +05:00
commit 71162ec2c6
2 changed files with 17 additions and 1 deletions

View file

@ -65,7 +65,12 @@ export default function ({
setInputText('')
}
const charHandler = event => {
const charHandler = event =>
(event.keyCode === 229
? charHandlerMobile
: charHandlerDefault)(event)
const charHandlerDefault = event => {
event.preventDefault()
const key =
@ -75,6 +80,12 @@ export default function ({
send(key)
}
const charHandlerMobile = event =>
setTimeout(_ => {
send(event.target.value.slice(-1).toUpperCase())
setInputText('')
})
const lineHandler = ({ keyCode, target: { value } }) => {
if (keyCode === keyCodes.KEY_RETURN) {
send(value)
@ -97,6 +108,10 @@ export default function ({
const inputHandlers = {
char: {
maxlength: '1',
autocapitalize: 'off',
autocorrect: 'off',
spellcheck: 'false',
placeholder: 'Press any key here',
onKeyDown: charHandler
},