Replace ^C with ^ in soft keyboard extension bar

box-drawing
cpsdqs 7 years ago
parent 310033b911
commit 842d1fd93c
Signed by untrusted user: cpsdqs
GPG Key ID: 3F59586BB7448DD1
  1. 18
      js/term/input.js
  2. 24
      js/term/soft_keyboard.js

@ -256,16 +256,23 @@ module.exports = function (conn, screen) {
'F5', 'F11', 'F12', 'Shift+F5' 'F5', 'F11', 'F12', 'Shift+F5'
] ]
let softModifiers = {
alt: false,
ctrl: false,
meta: false,
shift: false
}
const handleKeyDown = function (e) { const handleKeyDown = function (e) {
if (!shouldAcceptEvent()) return if (!shouldAcceptEvent()) return
if (cfg.no_keys) return if (cfg.no_keys) return
let modifiers = [] let modifiers = []
// sorted alphabetically // sorted alphabetically
if (e.altKey) modifiers.push('Alt') if (e.altKey || softModifiers.alt) modifiers.push('Alt')
if (e.ctrlKey) modifiers.push('Control') if (e.ctrlKey || softModifiers.ctrl) modifiers.push('Control')
if (e.metaKey) modifiers.push('Meta') if (e.metaKey || softModifiers.meta) modifiers.push('Meta')
if (e.shiftKey) modifiers.push('Shift') if (e.shiftKey || softModifiers.shift) modifiers.push('Shift')
let key = KEY_NAMES[e.which] || e.key let key = KEY_NAMES[e.which] || e.key
@ -455,7 +462,8 @@ module.exports = function (conn, screen) {
cfg.no_keys = yes cfg.no_keys = yes
}, },
handleKeyDown handleKeyDown,
softModifiers
} }
return input return input
} }

@ -122,7 +122,7 @@ module.exports = function (screen, input) {
'↓': 0x28, '↓': 0x28,
'↑': 0x26, '↑': 0x26,
'→': 0x27, '→': 0x27,
'^C': { which: 0x43, ctrlKey: true } Control: 'ctrl'
} }
for (const shortcut in shortcuts) { for (const shortcut in shortcuts) {
@ -132,12 +132,24 @@ module.exports = function (screen, input) {
shortcutBar.appendChild(button) shortcutBar.appendChild(button)
const key = shortcuts[shortcut] const key = shortcuts[shortcut]
button.addEventListener('click', e => { button.addEventListener('touchstart', e => {
if (typeof key === 'string') {
// modifier button
input.softModifiers[key] = true
// prevent default. This prevents scrolling, but also prevents the
// selection popup
e.preventDefault()
}
})
button.addEventListener('touchend', e => {
e.preventDefault() e.preventDefault()
let fakeEvent = key if (typeof key === 'number') {
if (typeof key === 'number') fakeEvent = { which: key } let fakeEvent = { which: key, preventDefault: () => {} }
fakeEvent.preventDefault = () => {} input.handleKeyDown(fakeEvent)
input.handleKeyDown(fakeEvent) } else if (typeof key === 'string') {
input.softModifiers[key] = false
}
}) })
} }
} }

Loading…
Cancel
Save