mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-12-28 05:29:33 +00:00
Capture Ctrl keys in keydown, not keypress
This commit is contained in:
parent
b3d42f944b
commit
45ee1b5c28
@ -53,7 +53,7 @@ export enum KeyFlags {
|
|||||||
export function _setKeyboardEvents(canvas:HTMLElement, callback:KeyboardCallback) {
|
export function _setKeyboardEvents(canvas:HTMLElement, callback:KeyboardCallback) {
|
||||||
canvas.onkeydown = (e) => {
|
canvas.onkeydown = (e) => {
|
||||||
callback(e.which, 0, KeyFlags.KeyDown|_metakeyflags(e));
|
callback(e.which, 0, KeyFlags.KeyDown|_metakeyflags(e));
|
||||||
if (e.which == 8 || e.which == 9 || e.which == 27) { // eat backspace, tab, escape keys
|
if (e.ctrlKey || e.which == 8 || e.which == 9 || e.which == 27) { // eat backspace, tab, escape keys
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -303,6 +303,18 @@ export class AppleII extends BasicScanlineMachine {
|
|||||||
case 39: code=21; break; // right
|
case 39: code=21; break; // right
|
||||||
case 38: code=11; break; // up
|
case 38: code=11; break; // up
|
||||||
case 40: code=10; break; // down
|
case 40: code=10; break; // down
|
||||||
|
default:
|
||||||
|
if (flags & KeyFlags.Ctrl) {
|
||||||
|
code = key;
|
||||||
|
if (code >= 0x61 && code <= 0x7a)
|
||||||
|
code -= 32;
|
||||||
|
if (key >= 65 && code < 65+26) {
|
||||||
|
code -= 64; // ctrl
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
code = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (code)
|
if (code)
|
||||||
this.kbdlatch = (code | 0x80) & 0xff;
|
this.kbdlatch = (code | 0x80) & 0xff;
|
||||||
|
Loading…
Reference in New Issue
Block a user