video-shortcut-controller
v1.0.1
Published
Add keyboard shortcut to <video> element.
Downloads
3
Readme
video-shortcut-controller
Add keyboard shortcut to <video>
element.
Installation
npm install video-shortcut-controller
Usage
var container = document.body;
var video = document.getElementById("video");
var VideoShortcutController = require("video-shortcut-controller");
var controller = new VideoShortcutController(container, video);
controller.start();
See example/
Default Keyboard chortcut
- Space
- toggle play/pause
- ↑ Up
- volume up
- ↓ Down
- volume down
- → Right
- seek forward
- ← Left
- seek backward
- S
- toggle track(subs)
- F
- toggle FullScreen
Custom Keyboard shortcut
import VideoShortcutController from "video-shortcut-controller";
class MyShortcutController extends VideoShortcutController{
onKeyCode(event, keyCode) {
// define custom key
switch (keyCode) {
case 32:
this.setPosition(100, 'forward');
return
}
return super.onKeyCode(event, keyCode);
}
super(event, keyCode);
}
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
License
MIT