Skip to content

A TypeScript namespace declaration for KeyboardEvent.key strings, just in case your code is allergic to enums.

Notifications You must be signed in to change notification settings

Heartade/ts-key-namespace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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");
  }
}}

About

A TypeScript namespace declaration for KeyboardEvent.key strings, just in case your code is allergic to enums.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published