shithub: puzzles

Download patch

ref: 9698732d659451d5f5216834f7eea0eba46a623e
parent: 322a439d801c91cf30a208cff499b33f4a5a2123
author: Ben Harris <bjh21@bjh21.me.uk>
date: Mon Oct 24 18:22:33 EDT 2022

js: Add modern "key" values for Delete and arrow keys

Firefox has emitted "Delete", "ArrowDown" etc since 2015.

--- a/emcc.c
+++ b/emcc.c
@@ -267,17 +267,18 @@
 {
     int keyevent = -1;
 
-    if (!strnullcmp(key, "Backspace") || !strnullcmp(key, "Del"))
+    if (!strnullcmp(key, "Backspace") || !strnullcmp(key, "Delete") ||
+        !strnullcmp(key, "Del"))
         keyevent = 127;                /* Backspace / Delete */
     else if (!strnullcmp(key, "Enter"))
         keyevent = 13;             /* return */
-    else if (!strnullcmp(key, "Left"))
+    else if (!strnullcmp(key, "ArrowLeft") || !strnullcmp(key, "Left"))
         keyevent = CURSOR_LEFT;
-    else if (!strnullcmp(key, "Up"))
+    else if (!strnullcmp(key, "ArrowUp") || !strnullcmp(key, "Up"))
         keyevent = CURSOR_UP;
-    else if (!strnullcmp(key, "Right"))
+    else if (!strnullcmp(key, "ArrowRight") || !strnullcmp(key, "Right"))
         keyevent = CURSOR_RIGHT;
-    else if (!strnullcmp(key, "Down"))
+    else if (!strnullcmp(key, "ArrowDown") || !strnullcmp(key, "Down"))
         keyevent = CURSOR_DOWN;
     else if (!strnullcmp(key, "End"))
         /*