mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-26 15:58:13 +01:00
Update html/poketube.ejs
This commit is contained in:
parent
ffa846d96d
commit
79b209fabe
1 changed files with 16 additions and 21 deletions
|
@ -633,10 +633,12 @@ background-color: #0000;
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener('keydown', function(event) {
|
document.addEventListener('keydown', function(event) {
|
||||||
// Toggle play/pause with the Spacebar and prevent control activation
|
const video = document.querySelector('video'); // Adjust if you have a different way to reference your video element
|
||||||
if (event.key === ' ' || event.key === 'Spacebar') {
|
|
||||||
|
// Toggle play/pause with the Spacebar
|
||||||
|
if (event.code === 'Space') {
|
||||||
event.preventDefault(); // Prevent default action, like activating buttons
|
event.preventDefault(); // Prevent default action, like activating buttons
|
||||||
if (video.paused()) {
|
if (video.paused) {
|
||||||
video.play();
|
video.play();
|
||||||
} else {
|
} else {
|
||||||
video.pause();
|
video.pause();
|
||||||
|
@ -644,34 +646,27 @@ document.addEventListener('keydown', function(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle fullscreen with the F key
|
// Toggle fullscreen with the F key
|
||||||
if (event.key === 'f' || event.key === 'F') {
|
if (event.code === 'KeyF') {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (video.isFullscreen()) {
|
if (document.fullscreenElement) {
|
||||||
video.exitFullscreen();
|
document.exitFullscreen();
|
||||||
} else {
|
} else {
|
||||||
video.requestFullscreen();
|
video.requestFullscreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle mute with the M key
|
// Toggle mute with the M key
|
||||||
if (event.key === 'm' || event.key === 'M') {
|
if (event.code === 'KeyM') {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
video.muted(!video.muted());
|
video.muted = !video.muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.ctrlKey || event.metaKey || event.altKey) {
|
// Seeking options with keys 1 to 9
|
||||||
return;
|
if (event.code >= 'Digit1' && event.code <= 'Digit9') {
|
||||||
}
|
|
||||||
|
|
||||||
var ewhich = event.which || event.keyCode;
|
|
||||||
|
|
||||||
// Number keys from 0-9 skip to a percentage of the video. 0 is 0% and 9 is 90%
|
|
||||||
if ((ewhich >= 48 && ewhich <= 57) || (ewhich >= 96 && ewhich <= 105)) {
|
|
||||||
var sub = ewhich >= 96 ? 96 : 48;
|
|
||||||
var number = ewhich - sub;
|
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
video.currentTime(video.duration * number * 0.1);
|
const percent = parseInt(event.code.replace('Digit', '')) * 10;
|
||||||
|
const time = (percent / 100) * video.duration;
|
||||||
|
video.currentTime = time;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue