-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Are keyboard shortcuts available ? #2859
Comments
For keyboard accessibility reasons, you can use tab to navigate to individual UI controls and manipulate them with the keyboard. For example, while the seek bar has focus, left and right arrows will seek. (Caveat: I just discovered that our focus indicator in the UI is broken. See #2863) We don't have any global keyboard shortcuts, though, but you can easily add these to the window or document with your own app-level event listener. For example: videoContainer = document.querySelector('.shaka-video-container');
document.addEventListener('keydown', (e) => {
if (e.key == 'f') {
videoContainer.requestFullscreen();
e.preventDefault();
} else if (e.key == ' ') {
if (video.paused) {
video.play();
} else {
video.pause();
}
e.preventDefault();
}
}); We wouldn't do this by default, because a global listener would be a bad idea for applications with more than one instance of Shaka Player. Does this help? |
It does, thanks! For people who want basics keyboard controls : document.addEventListener('keydown', (e) => {
const videoContainer = document.querySelector('video');
let is_fullscreen = () => !!document.fullscreenElement
let audio_vol = video.volume;
if (e.key == 'f') {
if (is_fullscreen()) {
document.exitFullscreen();
} else {
videoContainer.requestFullscreen();
}
e.preventDefault();
}
else if (e.key == ' ') {
if (video.paused) {
video.play();
} else {
video.pause();
}
e.preventDefault();
}
else if (e.key == "ArrowUp") {
e.preventDefault();
if (audio_vol != 1) {
try {
video.volume = audio_vol + 0.05;
}
catch (err) {
video.volume = 1;
}
}
}
else if (e.key == "ArrowDown") {
e.preventDefault();
if (audio_vol != 0) {
try {
video.volume = audio_vol - 0.05;
}
catch (err) {
video.volume = 0;
}
}
}
});
// Tested on Chrome 85 stable |
Have you read the Tutorials?
Almost yes.
Have you read the FAQ and checked for duplicate open issues?
Yes.
What version of Shaka Player are you using?
Lastest release
Please ask your question
Hi,
I'm wondering if it is possible to use keyboard shortcuts by any way ? I tried to use well-known 'space' and 'F' shortcut to pause and fullscreen but player didn't react. Is it implemented ? If yes, how can I enable them ? If no, is it planned ?
Thanks!
The text was updated successfully, but these errors were encountered: