UNPKG

@soundstep/soma

Version:

Soma is a javascript framework created to build scalable and maintainable applications.

28 lines (23 loc) 437 B
(function(snake) { 'use strict'; snake.Input = function(emitter) { document.addEventListener('keydown', function(event) { var key; switch (event.keyCode) { case 37: key = 'left'; break; case 38: key = 'up'; break; case 39: key = 'right'; break; case 40: key = 'down'; break; } emitter.dispatch('keydown', [key]); }.bind(this)); }; })(window.snake = window.snake || {});