aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/static/js/hotkeys.js
diff options
context:
space:
mode:
Diffstat (limited to 'youtube/static/js/hotkeys.js')
-rw-r--r--youtube/static/js/hotkeys.js19
1 files changed, 15 insertions, 4 deletions
diff --git a/youtube/static/js/hotkeys.js b/youtube/static/js/hotkeys.js
index c696ac0..b295db9 100644
--- a/youtube/static/js/hotkeys.js
+++ b/youtube/static/js/hotkeys.js
@@ -1,12 +1,11 @@
-Q = document.querySelector.bind(document);
-
function onKeyDown(e) {
if (['INPUT', 'TEXTAREA'].includes(document.activeElement.tagName)) return false;
- console.log(e);
+ // console.log(e);
let v = Q("video");
let c = e.key.toLowerCase();
- if (c == "k") {
+ if (e.ctrlKey) return;
+ else if (c == "k") {
v.paused ? v.play() : v.pause();
}
else if (c == "arrowleft") {
@@ -25,6 +24,18 @@ function onKeyDown(e) {
e.preventDefault();
v.currentTime = v.currentTime + 10;
}
+ else if (c == "f") {
+ e.preventDefault();
+ if (document.fullscreen) document.exitFullscreen();
+ else v.requestFullscreen();
+ }
+ else if (c == "c") {
+ e.preventDefault();
+ let tt = getActiveTranscriptTrack();
+ if (tt == null) return;
+ if (tt.mode == "showing") tt.mode = "disabled";
+ else tt.mode = "showing";
+ }
}
window.addEventListener('DOMContentLoaded', function() {