bind-keyboard
v0.0.11
Published
Lightweight Typescript library for managing keyboard event bindings and executing callback functions for specific key combinations
Downloads
43
Maintainers
Readme
bind-keyboard
bind-keyboard
is a lightweight Typescript library for managing keyboard event bindings and executing callback functions for specific key combinations. It's designed to simplify handling keyboard events in your web applications.
Features
- Easily bind callback functions to specific key combinations.
- Supports preventing repeated key press events when holding down a key.
- Prevents intercepting key events when typing in input fields.
- Debugging options for different levels of output.
Installation
You can install the "bind-keyboard" library via npm:
npm install bind-keyboard
Usage
To use "bind-keyboard," you need to create an instance of the BindKeyboard
class. This instance can be used to add and manage keyboard event bindings. Here's a basic example:
import { BindKeyboard } from "bind-keyboard";
// Create a BindKeyboard instance
const bindKeyboard = new BindKeyboard();
// Add a key binding for ctrl+a
bindKeyboard.add("ctrl+a", (event) => {
console.log("ctrl+a was pressed");
});
Examples
For more usage examples, please refer to the examples directory in the repository.
License
This project is licensed under the MIT License.