Hi,
Well I thought this was going to be straightforward, but I'm missing something regarding KEYDOWN.
I want to determine in the fastest time possible if the '5' key is pressed on the keypad portion of the keyboard. Using code in the IDKEYDOWN section of my 'mainw' subroutine, I can detect any of the keypad keys except the '5' key.
So I tried using KEYDOWN outside of 'mainw' with code like this:
CONST DIK_NUMPAD5 = 0x4C
IF KEYDOWN(DIK_NUMPAD5) THEN . . . . .
For whatever reason, this doesn't work. I tried it with the NUMLOCK key down and up with no luck I also tried other keypad keys and the regular keyboard keys with their own directinput constants but this command is never returning TRUE.
What am I missing??
Thanks again folks.
You might want to add this and see what the results look like:
SELECT @MESSAGE
case @IDCHAR
MOVE win,4,210
print win,"Ascii code = ",@CODE," "
case @IDKEYDOWN
MOVE win,4,240
print win,"virtual code = ",@CODE," "
Under @IDKEYDOWN, @CODE returns a 12 for keypad 5 (at least for me).
It will at least show you the values received from the system and it might help track down what you are looking for.
Bill
If you want the program to react on on a specific key and ignore all the others, you can use GETKEYSTATE:
case @IDKEYDOWN
if GETKEYSTATE(0x1B) then run=0 ' ESC is pressed
if GETKEYSTATE(0x21) then fq=fq+10 ' PG UP pressed
if GETKEYSTATE(0x22) then fq=fq-10 ' PG DOWN pressed
if GETKEYSTATE(0x26) then fq=fq+1 ' UP ARROW pressed
The expressions are true only if the particular keys are pressed.
Hexadecimal codes are found in the appendix to the Users Guide, under "Virtual key codes".
Good luck!
Egil