aboutsummaryrefslogtreecommitdiff
path: root/xP/public
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-07-22 23:47:33 +0200
committerPřemysl Eric Janouch <p@janouch.name>2023-07-23 00:20:32 +0200
commitc157d3369fd9fcd2ad314fe79960b647ff3a46a7 (patch)
treec48cfe2d229c877be5bfbe8ad1938f12cf27d9e7 /xP/public
parent8b5ea67aff71bfe0fc1f5cf3f11cda2303e03002 (diff)
downloadxK-c157d3369fd9fcd2ad314fe79960b647ff3a46a7.tar.gz
xK-c157d3369fd9fcd2ad314fe79960b647ff3a46a7.tar.xz
xK-c157d3369fd9fcd2ad314fe79960b647ff3a46a7.zip
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.
Diffstat (limited to 'xP/public')
-rw-r--r--xP/public/xP.js21
1 files changed, 17 insertions, 4 deletions
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)