ts-key-namespace
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

ts-key-namespace

A TypeScript namespace declaration for KeyboardEvent.key strings, just in case you prefer namespaces to enums. Largely based on ts-key-enum by Nathan Friend. ts-key-enum also probably works better.

Install

npm install ts-key-namespace --save

Import

import Key from "ts-key-namespace";

Example

onKeyDown={(ev: KeyboardEvent<HTMLInputElement>)=>{
  if(ev.key === Key.Enter) {
    console.log("Stuff");
  }
}}

Package Sidebar

Install

npm i ts-key-namespace

Weekly Downloads

4

Version

1.0.2

License

MIT

Unpacked Size

150 kB

Total Files

7

Last publish

Collaborators

  • heartade