RangerX
Member
Hi peeps,
This should be a simple problem to solve. Most probably am forgetting something really stupid. When I press Left key and Right key on the keyboard in very fast succession and hold them down, both the events related to the keys are being played --- while they should not. I thought I was blocking the keys and I even added a keyboard clear command for fun and it didn't fix it. Am at a loss here...
So why both user event 0 and user event 1 would play only when I press the keys in rapid succession??
If you press and hold them at reasonable speed, it works perfectly!!
------------------------- SOLVED -------------------------------
I did block it with variables. Looks like I was too tired yesterday to not think up such an easy thing...
This should be a simple problem to solve. Most probably am forgetting something really stupid. When I press Left key and Right key on the keyboard in very fast succession and hold them down, both the events related to the keys are being played --- while they should not. I thought I was blocking the keys and I even added a keyboard clear command for fun and it didn't fix it. Am at a loss here...
Code:
if(obj_Testing.Gamepad==false)
then
{
if(keyboard_check(global.K_left) && !keyboard_check(global.K_right))
then
{
keyboard_clear(global.K_right);
event_perform(ev_other,ev_user0);
}
if(keyboard_check(global.K_right) && !keyboard_check(global.K_left))
then
{
keyboard_clear(global.K_left);
event_perform(ev_other,ev_user1);
}
}
If you press and hold them at reasonable speed, it works perfectly!!
------------------------- SOLVED -------------------------------
I did block it with variables. Looks like I was too tired yesterday to not think up such an easy thing...
Code:
if(obj_Testing.Gamepad==false)
then
{
if(keyboard_check(global.K_left) && RightKey_pressed==false)
then
{
event_perform(ev_other,ev_user0);
LeftKey_pressed=true;
}
if(keyboard_check(global.K_right) && LeftKey_pressed==false)
then
{
event_perform(ev_other,ev_user1);
RightKey_pressed=true;
}
if(!keyboard_check(global.K_left) && LeftKey_pressed==true)
then
{
LeftKey_pressed=false;
}
if(!keyboard_check(global.K_right) && RightKey_pressed==true)
then
{
RightKey_pressed=false;
}
}
Last edited: