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

View file

@ -70,6 +70,7 @@
.ifplayer .output .gridBuffer { .ifplayer .output .gridBuffer {
flex-shrink: 0; flex-shrink: 0;
max-height: 100%;
border-bottom: var(--border-width) solid var(--main-color); border-bottom: var(--border-width) solid var(--main-color);
} }