da03 commited on
Commit
96dfb34
·
1 Parent(s): dfb2e77
Files changed (1) hide show
  1. static/index.html +23 -3
static/index.html CHANGED
@@ -575,12 +575,32 @@
575
 
576
  // Track keyboard events
577
  const TROUBLESOME = new Set([
578
- "Tab", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Space"
 
 
 
 
 
 
 
 
 
 
 
 
 
579
  ]);
580
 
 
 
 
 
 
 
 
 
581
  document.addEventListener("keydown", function (event) {
582
- // Prevent the browser from moving focus when Tab is pressed so it is sent to the backend instead
583
- if (TROUBLESOME.has(event.key)) {
584
  event.preventDefault();
585
  event.stopPropagation();
586
  }
 
575
 
576
  // Track keyboard events
577
  const TROUBLESOME = new Set([
578
+ "Tab", // focus change
579
+ " ", // Space - scrolls page
580
+ "Escape", // Esc
581
+ "ArrowUp", // scroll up
582
+ "ArrowDown", // scroll down
583
+ "ArrowLeft", // horiz. scroll or browser Back with Alt/⌥
584
+ "ArrowRight", // horiz. scroll or browser Forward with Alt/⌥
585
+ "Backspace", // navigate back in some browsers
586
+ "PageUp", // scroll
587
+ "PageDown", // scroll
588
+ "Home", // scroll to top
589
+ "End", // scroll to bottom
590
+ "Enter",
591
+ "Delete"
592
  ]);
593
 
594
+ function isForbiddenCombo(e) {
595
+ // Reload
596
+ if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "r") return true;
597
+ // Close tab
598
+ if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "w") return true;
599
+ return false;
600
+ }
601
+
602
  document.addEventListener("keydown", function (event) {
603
+ if (TROUBLESOME.has(event.key) || isForbiddenCombo(event)) {
 
604
  event.preventDefault();
605
  event.stopPropagation();
606
  }