Skip to content

Instantly share code, notes, and snippets.

@griffinmichl
Last active May 20, 2016 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save griffinmichl/876b079cf19404d8073f2214a2458ee5 to your computer and use it in GitHub Desktop.
Save griffinmichl/876b079cf19404d8073f2214a2458ee5 to your computer and use it in GitHub Desktop.
function getCharInRange(first, last) {
const charactersInRange = R.compose(R.map(keycode), R.range)
return charactersInRange(first, last)
}
const keystroke$ = getCharInRange(65, 91).reduce((acc$, char) =>
acc$.merge(Observable.zip(
DOM
.select(':root')
.events('keydown')
.map(eventToObject)
.filter(obj => obj.key === char),
DOM
.select(':root')
.events('keyup')
.map(eventToObject)
.filter(obj => obj.key === char)
)), Observable.empty())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment