Stuck key blur detection

Fixes #55
This commit is contained in:
Neale Pickett 2022-06-06 15:27:54 -06:00
parent d1edd13cc3
commit 6e20cc510f
1 changed files with 16 additions and 3 deletions

View File

@ -53,9 +53,7 @@ export class Keyboard extends Input{
// Listen for keystrokes
document.addEventListener("keydown", e => this.keyboard(e))
document.addEventListener("keyup", e => this.keyboard(e))
// VBand: the keyboard input needs to know whether vband's "left" should be dit or straight
this.iambic = false
window.addEventListener("blur", e => this.loseFocus(e))
}
keyboard(event) {
@ -103,6 +101,21 @@ export class Keyboard extends Input{
}
}
}
loseFocus(event) {
if (this.ditDown) {
this.keyer.Key(0, false)
this.ditDown = false
}
if (this.dahDown) {
this.keyer.Key(1, false)
this.dahDown = false
}
if (this.straightDown) {
this.keyer.key(2, false)
this.straightDown = false
}
}
}
export class MIDI extends Input{