Get started with keymaster CDN
MIT licensed
Lightweight jQuery plugin, Keymaster.js, handles keyboard shortcuts in JS apps.
Tags:- hotkeys
- hotkey
Stable version
Copied!
How to start using keymaster CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with keymaster CDN - cdnhub.io</title>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
<script src="https://cdn.cdnhub.io/keymaster/1.6.1/keymaster.min.js"></script>
<script>
$(document).ready(function() {
$(document).keypress(function(e) {
if (e.which === 32) { // Space key
alert('Space key pressed!');
}
});
$('#my-element').keymaster({
'up': function(e) { // Up arrow key
console.log('Up arrow key pressed on #my-element');
},
'down': function(e) { // Down arrow key
console.log('Down arrow key pressed on #my-element');
}
});
});
</script>
<style>
#my-element {
width: 100px;
height: 100px;
background-color: blue;
}
</style>
</head>
<body>
<button id="my-button">Press me</button>
<div id="my-element"></div>
</body>
</html>
Copied!
Copied!