// Generated by CoffeeScript 1.10.0 (function() { var Keyboard, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; global(Keyboard = (function(superClass) { extend(Keyboard, superClass); function Keyboard() { var events, keys, pressed_keys; keys = ['delete', 'ctrl', 'shift']; events = []; keys.forEach(function(d) { events.push(d + "_down"); return events.push(d + "_up"); }); Keyboard.__super__.constructor.call(this, { events: events }); pressed_keys = {}; document.onkeydown = (function(_this) { return function(e) { var key; key = _this.keyname(e.keyCode); if ((key != null) && !(key in pressed_keys)) { _this.trigger(key + '_down'); return pressed_keys[key] = true; } }; })(this); document.onkeyup = (function(_this) { return function(e) { var key; key = _this.keyname(e.keyCode); if ((key != null) && key in pressed_keys) { _this.trigger(key + '_up'); return delete pressed_keys[key]; } }; })(this); } Keyboard.prototype.keyname = function(keyCode) { switch (keyCode) { case 46: return 'delete'; case 17: return 'ctrl'; case 16: return 'shift'; default: return null; } }; return Keyboard; })(EventSource)); }).call(this);