Skip to content

A simple and easy-to-use function called `keyboard` that listens for and captures keyboard events

Notifications You must be signed in to change notification settings

kittykatattack/keyboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Keyboard

This repository hosts a simple and easy-to-use function called keyboard that listens for and captures keyboard events. It's really just a convenient wrapper function for HTML keyup and keydown events so that you can keep your application code clutter-free and easier to write and read.

Here's how to use the keyboard function. Create a new keyboard object like this:

var keyObject = keyboard(asciiKeyCodeNumber);

It's one argument is the ASCII key code number of the keyboard key that you want to listen for. Here's a list of ASCII key codes you can use. Then assign press and release methods to the keyboard object like this:

keyObject.press = function() {
  //key object pressed
};
keyObject.release = function() {
  //key object released
};

Keyboard objects also have isDown and isUp Boolean properties that you can use to check the state of each key.

About

A simple and easy-to-use function called `keyboard` that listens for and captures keyboard events

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages