Permalink
Browse files

Delete heldKeys when up. Makes for ... in work well.

  • Loading branch information...
1 parent 0e36446 commit 54332ae9e5d3a73ecd1100c3a8e59b1650e720b0 @wtaysom committed Apr 1, 2012
Showing with 9 additions and 1 deletion.
  1. +5 −1 isHoldingKey.js
  2. +4 −0 notes.md
View
@@ -36,7 +36,11 @@
function handler(event) {
var keyName = _MAP[event.keyCode] ||
String.fromCharCode(event.keyCode).toLowerCase();
- heldKeys[keyName] = event.type == 'keydown';
+ if (event.type == 'keydown') {
+ heldKeys[keyName] = true;
+ } else {
+ delete heldKeys[keyName];
+ };
};
global.addEventListener('keydown', handler, false);
View
@@ -138,6 +138,10 @@ Mouse events, keyboard events, libraries, parameter sliders.
Using the concepts we've learned so far. Think of some good game ideas.
+## Tools
+
+* isHoldingKey.js for telling which keys are held.
+
# Fun For Later
* [Hang Man Strategy](http://www.datagenetics.com/blog/april12012/index.html)

0 comments on commit 54332ae

Please sign in to comment.