keyb

1.6.1 • Public • Published

Keyb

A javascript utility for polling the state of the keyboard.

Usage

For any given frame of your game loop, you can poll if a key is being pressed using Keyb.isPressed(keyname):

if(Keyb.isPressed("W")) {
    player.position.y -= 1
}
if(Keyb.isPressed("S")) {
    player.position.y += 1
}
if(Keyb.isPressed("A")) {
    player.position.x -= 1
}
if(Keyb.isPressed("D")) {
    player.position.x += 1
}

All methods accept a keyname as defined in vkey, such as 1 or A or <enter>. Visit their test page to identify what keyname to use for each key on the keyboard.

License

This project is licensed under the MIT license.

Readme

Keywords

none

Package Sidebar

Install

npm i keyb

Weekly Downloads

42

Version

1.6.1

License

MIT

Unpacked Size

3.76 kB

Total Files

5

Last publish

Collaborators

  • ehgoodenough