Started working on keyboard input

This commit is contained in:
Leon Mika 2025-01-22 22:15:24 +11:00
parent 11f658afcc
commit cfe313c9a3
2 changed files with 15 additions and 1 deletions

View file

@ -6,6 +6,16 @@ export default class extends Controller {
static targets = [ "key" ];
static outlets = [ "playfield" ];
onKeyPress(ev) {
if ((ev.key >= 'a') && (ev.key >= 'z')) {
ev.preventDefault();
this.playfieldOutlet.tappedKey(ev.key);
} else if ((ev.key >= 'A') && (ev.key >= 'Z')) {
ev.preventDefault();
this.playfieldOutlet.tappedKey(ev.key.toLowerCase());
}
}
tappedKey(ev) {
ev.preventDefault();