Socket
Book a DemoInstallSign in
Socket

keyboard-tracker

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keyboard-tracker

Zero config keyboard tracker for JS.

latest
Source
npmnpm
Version
2.3.0
Version published
Maintainers
1
Created
Source

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 }] }

Keywords

keyboard

FAQs

Package last updated on 04 Mar 2018

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.