2.3.0 • Published 6 years ago

keyboard-tracker v2.3.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Keyboard Tracker

npm

Simple, zero dependency keyboard tracker for JS.

Installation:

<script type="text/javascript" src="https://unpkg.com/keyboard-tracker"></script>

Usage

new KeyboardTracker(handler[, options])

  • handler<Function, Object>:
    • <Function>: Receives one argument which contains the key which was pressed and any data the tracker has captured on that key.
    • <Object>: Will execute the function which key matches the key pressed. Can also contain a default property with a function to run if no matching key is found. Functions behave identically to the <Function> behaviour above.
  • options<Object>:

    • persistence<Boolean>: Set to true to save data between sessions using localStorage. Defaults to false.
    • history<Boolean>: Set to true to save every event with its timestamp. Defaults to false.
    • scope<Element>: The element to attach the event listeners to. Defaults to window.

Example

const tracker = new KeyboardTracker({ 'a': (e) => console.log(e) }, { history: true })

// press 'a' key
// => { key: 'a', pressed: true, total: 1, latest: 1520181191972, history: [{ state: 'down', timestamp: 1520181191972 }] }
2.3.0

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago