chiark / gitweb /
js: Avoid duplicate handling of keystrokes
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 3 Apr 2021 23:19:07 +0000 (00:19 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 4 Apr 2021 19:07:53 +0000 (20:07 +0100)
We didn't notice that keys you type into input boxes (currently, just
zoom) get fed to the play interpreter too, because you would only type
digits there which are ignored.

But we are about to pay attention to digits.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
templates/script.ts

index 761e5ee69f672d9a45ac9787494d17d6165f2ebb..a1aa33bf0bd2fc19ec74475ada917c59b0b11a09 100644 (file)
@@ -387,6 +387,11 @@ function some_keydown(e: KeyboardEvent) {
   // my tsc says this isComposing thing doesn't exist.  wat.
   if ((e as any).isComposing /* || e.keyCode === 229 */) return;
   if (e.ctrlKey || e.altKey || e.metaKey) return;
+  if (e.target) {
+    // someone else is dealing with it ?
+    let tag = (e.target as HTMLElement).tagName;
+    if (tag == 'INPUT') return;
+  }
 
   let pane = pane_keys[e.key];
   if (pane) {