keydown-event-dispatcher
v1.0.2
Published
Utility module for dispatching keydown events in web applications. Provides predefined key codes and a function to simulate keydown events programmatically. Compatible with JavaScript and TypeScript projects.
Downloads
15
Maintainers
Readme
Keydown Event Dispatcher
A utility module for dispatching keydown events in web applications. Provides predefined key codes and a function to simulate keydown events programmatically. Compatible with JavaScript and TypeScript projects.
Installation
You can install the Keydown Event Dispatcher module via:
npm
npm install keydown-event-dispatcher
pnpm
pnpm install keydown-event-dispatcher
yarn
yarn add keydown-event-dispatcher
Usage
- In projects using the CommonJS module system
const { triggerKeyboardEvent, KeyCodes } = require('keydown-event-dispatcher');
// Trigger an Enter key event on the document
triggerKeyboardEvent(document.body, KeyCodes.Enter);
- In projects using the ES6 module system
import { triggerKeyboardEvent, KeyCodes } from 'keydown-event-dispatcher';
// Trigger an Enter key event on the document
triggerKeyboardEvent(document.body, KeyCodes.Enter);
Key Codes
The module provides predefined key codes for common keyboard keys. Here are some examples:
KeyCodes.Enter
: Enter keyKeyCodes.ArrowUp
: Arrow Up keyKeyCodes.ArrowDown
: Arrow Down key- ...
For the full list of key codes, please refer to the source code.
Contributing
Contributions are welcome! If you find a bug or want to suggest a feature, please open an issue on GitHub or submit a pull request.
License
This project is licensed under the ISC License.