From 5fae5ca0db6a263d385c05cb6cfef5e3e3b18630 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Tue, 25 Oct 2022 20:38:37 +0100 Subject: js: Be more subtle about cancelling keydown events Now we only cancel a keydown event if the C keyboard handler recognises the key and passes it on to the midend. This doesn't necessarily mean that the midend has actually done anything with it, of course. Still, this is enough to allow F12 to open the developer tools even when the input focus is on the puzzle. It also allows for tabbing out of the puzzle into the links below it. --- emcc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'emcc.c') diff --git a/emcc.c b/emcc.c index 62ea9f8..3c9850a 100644 --- a/emcc.c +++ b/emcc.c @@ -260,9 +260,10 @@ void mousemove(int x, int y, int buttons) } /* - * Keyboard handler called from JS. + * Keyboard handler called from JS. Returns true if the key was + * handled and hence the keydown event should be cancelled. */ -void key(int keycode, const char *key, const char *chr, int location, +bool key(int keycode, const char *key, const char *chr, int location, bool shift, bool ctrl) { /* Key location constants from JavaScript. */ @@ -366,7 +367,9 @@ void key(int keycode, const char *key, const char *chr, int location, midend_process_key(me, 0, 0, keyevent); update_undo_redo(); + return true; /* We've probably handled the event. */ } + return false; /* Event not handled, because we don't even recognise it. */ } /* -- cgit v1.1