eternaldensity / Sandcastle-Builder

xkcd: 1190: Time: The Game
Other
79 stars 65 forks source link

Fix detecting the '5' key with numpads and azerty leopards #1456

Closed Pikrass closed 8 years ago

Pikrass commented 8 years ago

Clicking the beach requires to press 'f' then '5'. The detection of the '5' key in all possible configurations is a bit tricky, because the KeyboardEvent interface is such a mess.

Firstly, numpad keys have different keycodes (from 0x60 to 0x69 instead of 0x30 to 0x39). So we need to check for them individually.

Secondly, on LaPetite's weird azerty leopard, digits in the top row needs to be typed while holding shift (or control with some layouts). Control keys are considered normal keys by onkeydown, so the code remembers them as the previous key: the sequence becomes 'f' shift '5'. So we test for these keys and ignore them.