1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-21 07:33:14 +00:00

prevent backspace key from leaving browser page

This commit is contained in:
Steven Hugg 2019-09-08 18:36:59 -05:00
parent e45806e8cf
commit 818386a5d2
3 changed files with 10 additions and 2 deletions

View File

@ -3,7 +3,10 @@
.segment "INIT"
.segment "ONCE"
; don't use $800-$1fff :(
.segment "STARTUP"
jmp Start
; use $4000- :)
.segment "CODE"
.define EQU =
@ -146,7 +149,7 @@ PERFECT_AIM EQU $1
;==============================
; back up part of the zero page
;==============================
Start:
lda #>zero_page_save
sta BASH
lda #<zero_page_save
@ -3029,7 +3032,7 @@ check_paddles:
LDY #0 ;INIT COUNTER
NOP ;COMPENSATE FOR 1ST COUNT
NOP
PREAD2: LDA PADDL0,X ;COUNT EVERY 11 µSEC.
PREAD2: LDA PADDL0,X ;COUNT EVERY 11 uSEC.
BPL RTS2D ;BRANCH WHEN TIMED OUT
INY ;INCREMENT COUNTER
BNE PREAD2 ;CONTINUE COUNTING

View File

@ -53,6 +53,9 @@ 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
e.preventDefault();
}
};
canvas.onkeyup = (e) => {
callback(e.which, 0, KeyFlags.KeyUp|_metakeyflags(e));

View File

@ -243,7 +243,9 @@ export class AppleII extends BasicScanlineMachine {
} else if (flags & KeyFlags.KeyDown) {
code = 0;
switch (key) {
case 8: code=8; break; // left
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