New games every week!
JSE - KeyDown Blog
1st July 2021
Since I'm faffing about with buttons, I figured a Button command might be handy.

-=-=-

// KeyDown Tester // by Jayenkai // Created 2021/7/1 Graphics 820,480,1 SetFontSize 12 Repeat CLS for x=0 to 15 for y=0 to 7 k=(y*16)+x dx=(x+0.5)*51 dy=(y+0.5)*51 SetCol 255,255,255:Rect dx,dy,50,50,1 SetCol 0,0,0 if KeyDown(k) then SetCol 40,80,120 Rect dx,dy,46,46,1 SetCol 255,255,255 Text dx,dy-10,k,1 Text dx,dy+10,Chr$(k),1 next next if KeyDown(Asc("G")) then Text ScreenWidth()/2,ScreenHeight()-32,"HOLDING G!",1 Flip Forever


You'll note that the uppercase and lowercase letters get triggered together. I couldn't think of a good way to separate them without them breaking, so instead opted to just have everything happen together.
In the future I might "fix" that, but I imagine in most of the cases when you're scanning for "Key Down" then it really shouldn't matter.. Right!?!

Hmm..

.. Which is even odder when the symbols ARE sent as separate buttons, so a ; key is different to a : key, and so on.

Either way, it's probably not a good idea to trust/rely on the results of KeyDown. With all the browser/system/keyboard layouts and more, and without an exact button layout, you really shouldn't ever assume that this command will give the correct outputs.

That said. It does kinda work, so.. there's that.
You can use the above proggy to find numerical values, or you can use ASC("symbol goes here") to .. hopefully.. get the right key.
..
Maybe..
..
.... Sometimes.

Gawd, I wish Javascript was more specific about this stuff.
Views 83, Upvotes 12  
Jse , Input
New games every week!
Site credits : If you can see it, Jayenkai did it.
(c) Jayenkai 2023 and onwards, RSS feed 4

Blog - JSE - KeyDown - AGameAWeek