Skip to content

Instantly share code, notes, and snippets.

@bstro
Created August 4, 2013 06:42
Show Gist options
  • Save bstro/6149453 to your computer and use it in GitHub Desktop.
Save bstro/6149453 to your computer and use it in GitHub Desktop.
left = Bacon.fromEventTarget(document, 'keyup').map('.keyCode').filter((x) -> x is 37).map [-1,0]
up = Bacon.fromEventTarget(document, 'keyup').map('.keyCode').filter((x) -> x is 38).map [0,1]
right = Bacon.fromEventTarget(document, 'keyup').map('.keyCode').filter((x) -> x is 39).map [1,0]
down = Bacon.fromEventTarget(document, 'keyup').map('.keyCode').filter((x) -> x is 40).map [0,-1]
keys = Bacon.mergeAll(up,down,left,right).log()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment