Sha256: 6f2885f65ff9d0ddef00e2ca151e463ab13e5a31b1b49a92c075c48d3c3fa414
Contents?: true
Size: 821 Bytes
Versions: 3
Compression:
Stored size: 821 Bytes
Contents
var keys = (function() { var active = true; var bindings = {}; // Disable bindings. var disable = function() { active = false; } // Enable bindings. var enable = function() { active = true; } // Bind a key. var bind = function(code, fn) { if (bindings[code] === undefined) { bindings[code] = []; } bindings[code].push(fn); } // React to key presses. $(document).bind('keydown', function(ev) { if (active === false) { return; } var fns = bindings[ev.which]; if (fns !== undefined) { fns.forEach(function(fn) { fn(ev); }); // ev.preventDefault(); } }); return { active: function() { return active; }, bindings: function() { return bindings; }, bind: bind, enable: enable, disable: disable } })();
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
riemann-dash-0.2.8 | lib/riemann/dash/public/keys.js |
riemann-dash-0.2.7 | lib/riemann/dash/public/keys.js |
riemann-dash-0.2.6 | lib/riemann/dash/public/keys.js |