Name: cycle-keyboard
Owner: Cycle.js Community
Description: A keyboard driver for cycle.js
Created: 2016-07-05 13:18:57.0
Updated: 2017-11-16 03:33:04.0
Pushed: 2017-08-15 17:23:14.0
Homepage: null
Size: 366
Language: TypeScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A keyboard driver for cycle.js. View Demo
Install the package using node package manager
m install cycle-keyboard@1.0.0-rtm.4
Import the driver in your cycle app
rt { makeKeyboardDriver } from 'cycle-keyboard'
t drivers = {
.
yboard: makeKeyboardDriver()
Subscribe to keyboard-related event streams on the driver
tion main({ ..., keyboard }) {
nst keyUp$ = keyboard.ups().map(ev => ev.displayKey + ' was pressed');
The driver provides the following xstream streams:
ups(key?: number|string)
, a stream of all keyup events emitted on the document, with an additional displayKey
property, optionally filtered by a key code or a key namedowns(key?: number|string)
, a stream of all keydown events emitted on the document, with an additional displayKey
property, optionally filtered by a key code or a key namepresses(key?: number|string)
, a stream of all keypress events emitted on the document, with additional displayKey
and displayChar
properties, optionally filtered by a key code or a key nameshift$
, a stream of booleans indicating if the shift key is held down, andcapsLock$
, a stream of booleans indicating if the caps lock is on