if (window.innerWidth <= 700) { addEventListener('keydown', mirror); addEventListener('keyup', mirror); function mirror(e) { var oEvent = new KeyboardEvent(e.type, { keyCode: e.keyCode, which: e.which, code: e.code, key: e.key }); // Chromium hack Object.defineProperty(oEvent, 'keyCode', { get: function() { return e.keyCode } }); Object.defineProperty(oEvent, 'which', { get: function() { return e.which } }); document.getElementById('canvas').dispatchEvent(oEvent); } }