• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Unexpected behaviour with keyboard checks in HTML5

flerpyderp

Member
I have a game designed for Windows that I've made a HTML5 export version of just to share for testing etc. It appears as if keyboard_check_pressed functions are being treated like keyboard_checks instead.

For example, jumping is activated by a key press, but in the HTML5 version, holding jump causes the player to jump again upon landing.

I made a test project with only a room with one object which adds 1 to a counter each time a key is pressed and draws the value to the screen. Again, it appears to be checking for the key being held and adds 1 per frame. There is a slight delay between the first count, and all the ones that follow it.

Does anyone know why this might be happening? Since I can't find any information about this, I'm beginning to wonder if it's an issue specific to certain keyboards.

EDIT: Have now tested on a different keyboard, and it behaves the same.
 
Last edited:

flerpyderp

Member
If it's a bug... Do a very simple example, and file it with YoYo.
I forgot to mention I am using 1.4.9999.

Which version are you using? I know this bug did happen in older versions (1.4.9999 being affected as well).
Others have reported not having this issue using 1.4.9999. Since a lot of people still use it, I would expect to find reports of other people having the same issue, but I couldn't find any.
 

Mike

nobody important
GMC Elder
Well, if it's 1.4 there's nothing you can do except work around it - or upgrade.
 

rIKmAN

Member
Others have reported not having this issue using 1.4.9999. Since a lot of people still use it, I would expect to find reports of other people having the same issue, but I couldn't find any.
Just blew the dust off 1.4.9999 and tested this and can confirm I also get the bug where keyboard_check_pressed() acts like keyboard_check() when the key is held down when exporting to HTML5.

Have you tried with the previous version to see if it happens with that too?
Previous version was 1.4.1804 I think without checking?

It won't ever be fixed in 1.4.9999 so that might be your only hope without upgrading to GMS2.
 

flerpyderp

Member
Just blew the dust off 1.4.9999 and tested this and can confirm I also get the bug where keyboard_check_pressed() acts like keyboard_check() when the key is held down when exporting to HTML5.

Have you tried with the previous version to see if it happens with that too?
Previous version was 1.4.1804 I think without checking?

It won't ever be fixed in 1.4.9999 so that might be your only hope without upgrading to GMS2.
I appreciate you testing this. I have not tried it with the previous version.
 

TailBit

Member
Well, a workaround is to keep track of its last 2 states.

Create
Code:
key=0
Step
Code:
key = ((key&1)<<1) + keyboard_check(vk_anykey)
Then you can check if it is pressed, held or released with key==1, key&3 and key==2

I have an array that does this check for all my keys, and have scripts for the press/release checks with array position as argument
 
Top