mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-22 14:33:51 +00:00
Merge pull request #94 from micahcowan/kbdinput
Grab control-key keyboard input
This commit is contained in:
commit
4076b742fe
@ -53,7 +53,7 @@ export enum KeyFlags {
|
||||
export function _setKeyboardEvents(canvas:HTMLElement, callback:KeyboardCallback) {
|
||||
canvas.onkeydown = (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();
|
||||
}
|
||||
};
|
||||
|
@ -339,13 +339,32 @@ export class AppleII extends BasicScanlineMachine implements AcceptsBIOS {
|
||||
} else if (flags & KeyFlags.KeyDown) {
|
||||
code = 0;
|
||||
switch (key) {
|
||||
case 8: code=8; break; // left
|
||||
case 8:
|
||||
code=8; // left
|
||||
if (flags & KeyFlags.Ctrl) {
|
||||
// (possibly) soft reset
|
||||
this.cpu.reset();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 13: code=13; break; // return
|
||||
case 27: code=27; break; // escape
|
||||
case 37: code=8; break; // left
|
||||
case 39: code=21; break; // right
|
||||
case 38: code=11; break; // up
|
||||
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)
|
||||
this.kbdlatch = (code | 0x80) & 0xff;
|
||||
|
Loading…
Reference in New Issue
Block a user