Test the compatibility of hotkeys-js library across different module formats and environments
Test loading and basic functionality of hotkeys-js library in different build formats
Immediately Invoked Function Expression, suitable for direct browser use
Press F1 to test
Universal Module Definition, compatible with CommonJS, AMD and global variables
Press F2 to test
Modern ES6 module format, requires server environment
Press F3 to test
Test various hotkey combinations and functions
Test various API methods provided by hotkeys-js
import hotkeys from 'hotkeys-js';
hotkeys('ctrl+k', function(event, handler) {
event.preventDefault();
console.log('Hotkey pressed!');
});
const hotkeys = require('hotkeys-js');
// or
const hotkeys = require('hotkeys-js').default;
hotkeys('ctrl+k', function(event, handler) {
event.preventDefault();
console.log('Hotkey pressed!');
});
<script src="hotkeys-js/dist/hotkeys-js.min.js"></script>
<script>
hotkeys('ctrl+k', function(event, handler) {
event.preventDefault();
console.log('Hotkey pressed!');
});
</script>