从KeyboardEvent探测键盘事件类型:key-string

jopen 10年前

从KeyboardEvent探测键盘事件类型:key-string。

Install

npm install key-string

Usage

import KeyStringDetector from 'key-string'    const detector = new KeyStringDetector();  detector.detect(event); //=> "Alt+Ctrl+Return"

Import

Import in your favorite style.

import KeyStringDetector from 'key-string'    // Pattern 2: Using named exports  import { KeyStringDetector, keyStringMap } from 'key-string'    // Pattern 3: Using both a default export and named exports  import KeyStringDetector, { keyStringMap } from 'key-string'

Example

import { KeyStringDetector } from 'key-string'    const detector = new KeyStringDetector();    document.addEventListener('keydown', (event) => {    console.log(detector.detect(event));  });

项目主页:http://www.open-open.com/lib/view/home/1442815583716