PDA

View Full Version : Tab Kills Input



Xaotique
09-07-2013, 02:23 PM
When playing, if you press tab it will lose focus of the game. Clicking the game doesn't solve this problem though. You have to click outside of the game, then back into it to have keyboard input once again. You can still input via mouse, but keyboard fails until clicking out and back in.

Not sure if this belongs under suggestions or what, but it would be nice to have tab input blocked if possible. Not sure of what all is allowed under Chrome games, but simple javascript can fix this. For example, adding the following does the trick.


window.addEventListener("keydown", function(e)
{
if (e.keyCode == 9)
{
e.preventDefault();
return false;
}

return true;
}, false);

I know I can fix this with a greasemonkey (tampermonkey) script using the above, but it would be nicer if that weren't necessary.

Note: If not obvious at this point, it's on Chrome that this is an issue.

GoodSyntax
09-07-2013, 02:26 PM
Side note.....anonymous functions such as this are not really desirable as they are parsed at the moment of the event handler script.

I would suggest that you create a defined function instead of an anonymous one.

Xaotique
09-07-2013, 02:35 PM
Eh, Chrome blocks adding scripts to the page. So, a GM script wouldn't suffice, but you could add it in after. That's just a pain though. Probably wouldn't bother.

GoodSyntax
09-07-2013, 03:09 PM
You can add it as an browser extension...I'd have to look up the code to do that, but for such a silly little script, it's not worth the overhead of an additional Chrome.exe process for just this.