Can I disable some keyboard shortcuts of the embedded Vimeo video instead of disabling all shortcuts?
I often embed the Vimeo video via iframe into my website for video conferencing. I need to hide the control bar and disable all shortcuts except the shortcut "F"
Is there a way to achieve this?
Thanks
Please try the code by saving locally on your device or using any third party Code Compiler as Stack Overflow is not allowing 'fullscreen', and make sure the iframe is active or focussed.
var options = {
id: 59777392, //Video Id
width: 640,
keyboard: false,
};
var player = new Vimeo.Player('VimeoVideo', options);
player.on('play', function() {
window.focus()
});
player.on('pause', function() {
window.focus()
});
window.addEventListener("blur", () => {
{
if (document.activeElement.tagName === "IFRAME") {
check(); //Checks if Iframe is already in Full Screen
}
};
});
function check(){
if(window.innerHeight !== screen.height) { //If the Iframe is not full screen then make it full screen when user presses 'F', this will work only after the Vimeo Video Iframe has completed loading.
document.addEventListener("keydown", event => {
if (event.isComposing || event.keyCode !== 70) {
return;
}
player.requestFullscreen();
})}
else{
document.addEventListener("keydown", event => {//If the Iframe is in full screen then make it normal, this function might not be executed if user do not interacts.
if (event.isComposing || event.keyCode !== 70) {
return;
}
player.exitFullscreen();
})
}
}
<!-- The Keyboard is disbaled and only 'F' key is enabled -->
<div id="VimeoVideo"></div>
<script src="https://player.vimeo.com/api/player.js"></script>