From cc027e9a7d9c3707631fd366548885be0a69846c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 9 Apr 2021 18:57:54 +0100 Subject: [PATCH] script: Suppress default actions of our keystrokes In particular, this means that pressing SPC to cancel a special selection mode will no longer scroll the main window. Signed-off-by: Ian Jackson --- templates/script.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/templates/script.ts b/templates/script.ts index 66bcf575..5cc48fb8 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -429,27 +429,35 @@ function some_keydown(e: KeyboardEvent) { if (tag == 'INPUT') return; } + let y = function() { e.preventDefault(); e.stopPropagation(); } + let pane = pane_keys[e.key]; if (pane) { + y(); return pane_switch(pane); } let special_count_key = parseInt(e.key); if (isFinite(special_count_key)) { + y(); if (special_count == null) special_count = 0; special_count *= 10; special_count += special_count_key; special_count %= 100; special_count_reupdate(); + return; } if (e.key == ' ') { + y(); special_count = null; special_count_reupdate(); + return; } let uo = uo_map[e.key]; if (uo === undefined || uo === null) return; + y(); console.log('KEY UO', e, uo); if (uo.kind == 'Client' || uo.kind == 'ClientExtra') { let f = keyops_local[uo.opname]; -- 2.30.2