aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2022-07-20 03:49:28 +0200
committerTeddy Wing2022-07-20 03:49:28 +0200
commit94c30fef65a1beb49e65860c7ed99964e9c162e2 (patch)
treeab1d90c06ae79d126adc4024ae928be3d7b705aa
parentde8013b706108713397158ac0bb0ce8ed32015de (diff)
downloadGitHub-Apple-Option-P-to-Preview-94c30fef65a1beb49e65860c7ed99964e9c162e2.tar.bz2
Attach key event listener to `<html>` instead of `<body>`
Recently I noticed that sometimes the shortcut didn't work. The CSS classes and HTML structure didn't change. The shortcut stopped working after a navigation action. Maybe Turbolinks replaces `<body>` now? Regardless, attaching the event listener to an element higher in the tree allows the shortcut to continue working even after navigation.
-rw-r--r--github-apple-option-p-to-preview.user.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/github-apple-option-p-to-preview.user.js b/github-apple-option-p-to-preview.user.js
index 6442a46..7c9dafb 100644
--- a/github-apple-option-p-to-preview.user.js
+++ b/github-apple-option-p-to-preview.user.js
@@ -23,7 +23,7 @@
var KEY_CODE_P = 80;
-document.body.addEventListener(
+document.documentElement.addEventListener(
'keydown',
function(e) {
var node = e.target;