Blazekey is a JavaScript library that provides an easy way to handle keyboard events in your web applications. It allows you to define key combinations and assign specific actions to them.
-
😍 Easy to use: Blazekey provides a simple and intuitive API for handling keyboard events.
-
🪶 Lightweight: Blazekey is a small and lightweight library that won't bloat your web applications.
-
📦 No dependencies: Blazekey has no dependencies and can be used in any web application.
npm install blazekey
# or
yarn add blazekey
Then, you can define a key combination and assign an action to it using the blazekey function. The function takes two arguments: a string representing the key combination and a callback function that is executed when the key combination is pressed.
import blazekey from "blazekey";
blazekey("shift + s", (event) => {
event.preventDefault();
console.log("You pressed the keys: shift + s");
});
// or
blazekey("ctrl + shift + a", (event) => {
event.preventDefault();
console.log("You pressed the keys: ctrl + shift + a");
});
The blazekey.combination
function is a method provided by the Blazekey. This function allows you to define a specific combination of keys as a trigger for a certain action in your web application.
import blazekey from "blazekey";
const konamiCode = [
"ArrowUp",
"ArrowUp",
"ArrowDown",
"ArrowDown",
"ArrowLeft",
"ArrowRight",
"ArrowLeft",
"ArrowRight",
"b",
"a",
];
blazekey.combination(konamiCode, (ev) => {
ev.preventDefault();
window.location.href = "https://www.youtube.com/watch?v=dQw4w9WgXcQ";
});
You can support me by donating me on PayPal
BlazekeyJS is licensed under the MIT License. See LICENSE for more information.