More cleverness in midend_process_key()

It now strips off modifier flags from keys that shouldn't have them and
maps printable characters with MOD_CTRL to the corresponding control
characters.  It also catches Ctrl+Shift+Z because that obviously belongs
in the midend.

I've updated the JavaScript front-end to take advantage of these
changes.  Other front ends are unchanged and should work just as they
did before.
This commit is contained in:
Ben Harris
2023-02-23 22:32:53 +00:00
parent 015bd14474
commit 9dbcfa765b
3 changed files with 27 additions and 15 deletions

16
emcc.c
View File

@ -408,19 +408,9 @@ bool key(int keycode, const char *key, const char *chr, int location,
keyevent = keycode;
if (keyevent >= 0) {
if (shift && (keyevent >= 0x100 && !IS_UI_FAKE_KEY(keyevent)))
keyevent |= MOD_SHFT;
if (ctrl && !IS_UI_FAKE_KEY(keyevent)) {
if (keyevent >= 0x100)
keyevent |= MOD_CTRL;
else
keyevent &= 0x1F;
}
if ('0' <= keyevent && keyevent <= '9' &&
location == DOM_KEY_LOCATION_NUMPAD)
keyevent |= MOD_NUM_KEYPAD;
if (shift) keyevent |= MOD_SHFT;
if (ctrl) keyevent |= MOD_CTRL;
if (location == DOM_KEY_LOCATION_NUMPAD) keyevent |= MOD_NUM_KEYPAD;
midend_process_key(me, 0, 0, keyevent, &handled);
post_move();