A declarative library designed to handle modifier key states
npm install modifier-keysprimaryKey and secondaryKey- Primary Key - set to be Command or Control depending on the operating system
- Secondary Key - set to be Alt
Can also parse key commands to string according to the environment (e.g. Ctrl+C)
Using Yarn:
``sh`
yarn add modifier-keys
Using npm:
`sh`
npm install modifier-keys --save
Importing:
`js`
import Modifier from 'modifier-keys';
`jsx
import Modifier from 'modifier-keys';
function handleKeyDown(e) {
e.primaryKey; // bool
e.secondaryKey; //bool
}
`
`jsx
import { modifier } from 'modifier-keys';
function handleKeyDown(e) {
let event = modifier(e);
event.primaryKey; // bool
event.secondaryKey; //bool
}
`
(string that will be capitalized) and options
`js
import { parse } from 'modifier-keys';parse('c', { primaryKey: true }); // ⌘C or Ctrl+C
`#### Options
-
primaryKey - bool, to include or not the environment's primary key
- secondaryKey` - bool, to include or not the environment's secondary key