+
+function keyevent_to_action(e) {
+
+ const hotkeys_map = getInitParam("hotkeys");
+ const keycode = e.which;
+ const keychar = String.fromCharCode(keycode).toLowerCase();
+
+ if (keycode == 27) { // escape and drop prefix
+ hotkey_prefix = false;
+ }
+
+ if (keycode == 16 || keycode == 17) return; // ignore lone shift / ctrl
+
+ if (!hotkey_prefix && hotkeys_map[0].indexOf(keychar) != -1) {
+
+ const date = new Date();
+ const ts = Math.round(date.getTime() / 1000);
+
+ hotkey_prefix = keychar;
+ hotkey_prefix_pressed = ts;
+
+ $("cmdline").innerHTML = keychar;
+ Element.show("cmdline");
+
+ e.stopPropagation();
+
+ return false;
+ }
+
+ Element.hide("cmdline");
+
+ let hotkey_name = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")";
+
+ // ensure ^*char notation
+ if (e.shiftKey) hotkey_name = "*" + hotkey_name;
+ if (e.ctrlKey) hotkey_name = "^" + hotkey_name;
+ if (e.altKey) hotkey_name = "+" + hotkey_name;
+ if (e.metaKey) hotkey_name = "%" + hotkey_name;
+
+ const hotkey_full = hotkey_prefix ? hotkey_prefix + " " + hotkey_name : hotkey_name;
+ hotkey_prefix = false;
+
+ let action_name = false;
+
+ for (const sequence in hotkeys_map[1]) {
+ if (sequence == hotkey_full) {
+ action_name = hotkeys_map[1][sequence];
+ break;
+ }
+ }
+
+ console.log('keyevent_to_action', hotkey_full, '=>', action_name);
+
+ return action_name;
+}
\ No newline at end of file