From c157d3369fd9fcd2ad314fe79960b647ff3a46a7 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Sat, 22 Jul 2023 23:47:33 +0200 Subject: xP: make Page Up/Down in editor scroll the buffer Just like in xW recently. It is unlikely that the user would want to use these keys to move the cursor. Ctrl+Home/End still work, as does holding Up/Down arrows. Also stop using the deprecated and somewhat cryptic keyCode. --- xP/public/xP.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'xP') diff --git a/xP/public/xP.js b/xP/public/xP.js index 64fa542..5dd578d 100644 --- a/xP/public/xP.js +++ b/xP/public/xP.js @@ -1013,10 +1013,23 @@ let Input = { } else if (!event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) { handled = true - switch (event.keyCode) { - case 9: success = Input.complete(b, textarea); break - case 13: success = Input.submit(b, textarea); break - default: handled = false + switch (event.key) { + case 'PageUp': + Array.from(document.getElementsByClassName('buffer')) + .forEach(b => b.scrollBy(0, -b.clientHeight)) + break + case 'PageDown': + Array.from(document.getElementsByClassName('buffer')) + .forEach(b => b.scrollBy(0, +b.clientHeight)) + break + case 'Tab': + success = Input.complete(b, textarea); + break + case 'Enter': + success = Input.submit(b, textarea); + break + default: + handled = false } } if (!success) -- cgit v1.2.3-70-g09d2