Skip to content

Commit c8d78bb

Browse files
authored
add block
1 parent 27a2b3a commit c8d78bb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,22 +399,24 @@
399399

400400
<!-- Block -->
401401
<script>
402-
document.addEventListener('keydown', function(e) {
402+
window.addEventListener('keydown', function(e) {
403403
const isControlOrCommand = e.ctrlKey || e.metaKey;
404404
const key = e.key ? e.key.toUpperCase() : '';
405+
const blockedNavigation = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Home', 'End'];
405406
if (isControlOrCommand && key === 'F') {
406407
e.preventDefault();
407408
toggleFullscreen();
408409
return false;
409410
}
410-
if (e.keyCode === 123 || (isControlOrCommand && key === 'D') || (isControlOrCommand && key === 'K') || (isControlOrCommand && key === 'P') || (isControlOrCommand && key === 'O') || (isControlOrCommand && key === 'E') || (isControlOrCommand && key === 'H') || (isControlOrCommand && key === 'S') || (isControlOrCommand && key === 'U') || (isControlOrCommand && key === 'G') || (isControlOrCommand && key === 'V') || (isControlOrCommand && e.shiftKey && (key === 'I' || key === 'J' || key === 'C'))) {
411+
if (e.keyCode === 123 || blockedNavigation.includes(key) || (isControlOrCommand && ['D', 'K', 'P', 'O', 'E', 'H', 'S', 'U', 'G', 'V'].includes(key)) || (isControlOrCommand && e.shiftKey && ['I', 'J', 'C'].includes(key))) {
411412
e.preventDefault();
412413
return false;
413414
}
414-
});
415+
}, false);
415416
</script>
416417
</body>
417418
</html>
418419

419420

420421

422+

0 commit comments

Comments
 (0)