diff options
| author | Teddy Wing | 2022-07-20 03:49:28 +0200 |
|---|---|---|
| committer | Teddy Wing | 2022-07-20 03:49:28 +0200 |
| commit | 94c30fef65a1beb49e65860c7ed99964e9c162e2 (patch) | |
| tree | ab1d90c06ae79d126adc4024ae928be3d7b705aa /github-apple-option-p-to-preview.user.js | |
| parent | de8013b706108713397158ac0bb0ce8ed32015de (diff) | |
| download | GitHub-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.
Diffstat (limited to 'github-apple-option-p-to-preview.user.js')
| -rw-r--r-- | github-apple-option-p-to-preview.user.js | 2 |
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; |
