# HG changeset patch # User Oleksandr Gavenko # Date 1410388556 -10800 # Node ID 518ab579d24b8b79cdf3e325a24ee307b73ca8fa # Parent 8b1577211149f09e8952701a590a9b9c0bd7b23b Prevent from blocking Firefox key binding. diff -r 8b1577211149 -r 518ab579d24b 2048.html --- a/2048.html Wed Sep 10 20:41:49 2014 +0300 +++ b/2048.html Thu Sep 11 01:35:56 2014 +0300 @@ -436,16 +436,13 @@ document.body.addEventListener("keydown", function(event) { if (document.activeElement.value) - return false; + return; var key = event.keyCode || event.which; - switch (key) { - case 38: ui.action.up(); break; - case 40: ui.action.down(); break; - case 37: ui.action.left(); break; - case 39: ui.action.right(); break; + var keyMoves = {38: "up", 40: "down", 37: "left", 39: "right"}; + if (key in keyMoves) { + ui.action[keyMoves[key]](); + event.preventDefault(); } - event.preventDefault(); - return false; }); document.getElementById("test").addEventListener("click", function() {