• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

GMS 2.3+ How to judge if 2 keys are pressed together

tomlee2020

Member
i use code
if (keyboard_check_pressed(ord("K")) &&keyboard_check_pressed(ord("J")))
{
sprite_index=Spr_hana_baoxian;
state=3;
}
but i test and find it is Invalid
who can help me? thank you!
 

kburkhart84

Firehammer Games
You should say what you mean by "invalid." Do you get an error? Or does it simply not work? What does it do?
 

WithoutHope

Member
strange, this works for me

GML:
if (keyboard_check(ord("K")) and keyboard_check(ord("J"))) { show_debug_message("check"); }
perhaps the sprite or state variable is being changed somewhere else
 
Last edited:

kupo15

Member
i use code
if (keyboard_check_pressed(ord("K")) &&keyboard_check_pressed(ord("J")))
{
sprite_index=Spr_hana_baoxian;
state=3;
}
but i test and find it is Invalid
who can help me? thank you!
for that code to work you need to press both keys at the same time on the same frame. Do what withoutHope says to do above
 

rytan451

Member
If you want to check if they're pressed at a very similar time (usually though of as "at the same time" by most people), then you'd need a timer.
 
Top