Help with multiple key detection
#1

I am trying to do it so that if you press Y and H at the same time it will trigger some code to work.

if (PRESSED( KEY_YES | KEY_CTRL_BACK))

It doesn't work.
Reply
#2

What's your code for "PRESSED"?
Reply
#3

Quote:
Originally Posted by JaydenJason
View Post
What's your code for "PRESSED"?
#if !defined PRESSED
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#endif
Reply
#4

Code:
if(PRESSED(KEY_YES) && PRESSED(KEY_CTRL_BACK))
{
      // code ere
}
Reply
#5

pawn Code:
if (PRESSED( KEY_YES | KEY_CTRL_BACK))
{
    printf("called");
}
There's currently no code, I am reserving the key combinations for further use, the code to execute is not ready yet. However, for testing sake, I got the code above at the moment.

Quote:
Originally Posted by JaydenJason
View Post
Code:
if(PRESSED(KEY_YES) && PRESSED(KEY_CTRL_BACK))
{
      // code ere
}

This doesn't work.
Reply
#6

Your code may be ok, but some keyboards don't accept multiple keypresses with characters (the alphabet characters).
Pressing Y + H are 2 character keys at once and may not work.

Pressing multiple special keys (CTRL, ALT, SHIFT) along with a character key is allowed on most keyboards (if not all), but not multiple character keys.

Some of your players may not be able to execute your code because their keyboard doesn't support it.
Yours might not accept it either and your code will not trigger.
Reply
#7

Quote:
Originally Posted by PowerPC603
View Post
Your code may be ok, but some keyboards don't accept multiple keypresses with characters (the alphabet characters).
Pressing Y + H are 2 character keys at once and may not work.

Pressing multiple special keys (CTRL, ALT, SHIFT) along with a character key is allowed on most keyboards (if not all), but not multiple character keys.

Some of your players may not be able to execute your code because their keyboard doesn't support it.
Yours might not accept it either and your code will not trigger.
You are right, thanks a lot!
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)