keydown-listener
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

keydown-listener

监听按键,返回web页面中按下的按键

keydownListener for website, return an pressing keys array


特性

  • 使用 TypeScript 编写,提供完善的类型定义
  • 使用原生 javascript Api,支持跨框架使用

安装

// npm
npm install keydown-listener --save

用法

import keydownListener from "keydown-listener";

const keyGen = keydownListener()

console.log(keyGen.keys)
参数 说明 类型 默认值
element 监听事件的DOM Element document
onkeydown 按下按键时的回调函数 (val: {keys: string[], events: KeyboardEvent[]}) => void undefined
onkeyup 放开按键时的回调函数 (val: {keys: string[], events: KeyboardEvent[]}) => void undefined

线上Demo

Package Sidebar

Install

npm i keydown-listener

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

6.59 kB

Total Files

7

Last publish

Collaborators

  • op_chen