blazekey

0.1.1 • Public • Published

Blazekey | Keyboard Event Handling Made Easy 🔥

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.

Features

  • 😍 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.

Installation

npm install blazekey
# or
yarn add blazekey

Usage

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.

Here's an example:

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.

Here's another example:

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";
});

Donate

You can support me by donating me on PayPal

License

BlazekeyJS is licensed under the MIT License. See LICENSE for more information.

Package Sidebar

Install

npm i blazekey

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

13.7 kB

Total Files

5

Last publish

Collaborators

  • cresvin