|
|
@ -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 |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|