concord
concord copied to clipboard
Concord keyboard handling
I've been trying to fit a more powerful keystroke capturer under Concord's keyboard handling code, but I'm ready to debug the resulting code. The problem is that none of the JavaScript key handlers will decode an existing event, they have to actually capture the event and call back to the app. Maybe there's an exception, if such a toolkit exists, that would make the systematization of Concord's keystroke handling simple enough to attempt.
Two examples I've considered -- keypress and hotkeys.
To be clear, what I need is this.
$(document).on ("keydown", function (event) {
var cmdString = keyboardManager.process (event);
switch (cmdString) {
case "uparrow":
moveCursorUp ();
break;
//more cases follow
})
I get that this is hard to do given the browsers ridiculous model for keystroke handling. This kind of stuff should be baked into the browser. The event should have a string that virtualizes the keyboard. Only a videogame or serious graphics app needs the kind of power in the interface for the keyboard, but we all have to handle all the keys as separate events.
This seems useful.
https://w3c.github.io/uievents/tools/key-event-viewer.html
The P5 library has something like this : https://p5js.org/reference/#/p5/keyPressed
I don't know if that's useful