Neovictorian Paisley Menswear
Miss any of our Open RFC calls?Watch the recordings here! »

keycon

1.1.0 • Public • Published

keycon npm version

Keyboard Controller

Installation

npm i keycon
<script src="https://daybrush.com/keycon/release/latest/dist/keycon.pkgd.min.js"></script>

How to use

import KeyController, { getCombi, getKey } from "keycon";
 
const keycon = new KeyController();
 
// The focus went out of the browser.
keycon.on("blur", () => {
    console.log("blur");
});
// keydown all
keycon.keydown(e => {
    console.log(e);
});
// keydown space
keycon.keydown("space", e => {
    console.log(e);
});
// keydown alt + space combination
keycon.keydown(["alt", "space"], e => {
    // ["alt", "space"]
    console.log(getCombi(e));
    // "space"
    console.log(getKey(e.keyCode));
 
    console.log(e);
});
 
// keyup all
keycon.keyup(e => {
    console.log(e);
});
// keyup space
keycon.keydown("space", e => {
    console.log(e);
});
// keyup alt + space combination
keycon.keyup(["alt", "space"], e => {
    console.log(e);
});

Install

npm i keycon

DownloadsWeekly Downloads

632

Version

1.1.0

License

MIT

Unpacked Size

110 kB

Total Files

21

Last publish

Collaborators

  • avatar