Socket
Book a DemoInstallSign in
Socket

@brendangooch/keyboard-input

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brendangooch/keyboard-input

a class that listens for and processes keydown events on the document body before dispatching its own custom events for the client to listen for

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
0
Created
Source

keyboard-input

a class that listens for and processes keydown events on the document body before dispatching its own custom events for the client to listen for

simply drop the class into your project, turn it on, and tell it which custom events to dispatch

const input = new KeyboardInput();
input.enable([
    'a-key-pressed',
    'ctrl-a-pressed',
    'ctrl-k-pressed',
    'left-key-pressed',
    'right-key-pressed',
    'shift-left-pressed',
    'shift-right-pressed',
    'spacebar-pressed',
    'enter-pressed'
]);
input.turnOn();
document.addEventListener('ctrl-a-pressed', () => console.log('you pressed Ctrl A'));
document.addEventListener('spacebar-pressed', () => console.log('you pressed the spacebar'));
// ...

FAQs

Package last updated on 20 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts