Computer Science Canada

ID for keys in number pad

Author:  isaiahk9 [ Sun May 11, 2008 2:41 pm ]
Post subject:  ID for keys in number pad

I want to make some controls in my game (Number pad 1 - 6), but when I go
elsif key (KEY_KEYPAD_5) then
where key is a variable for the key being pressed, this only works for the number pad 5, not any others. So what is the ID of the keys Numberpad 1, 2, 3, 4, 6? I would use it in a
Input.KeyDown (key)
type of format.
Does any one know?
Thanx.

Author:  Tony [ Sun May 11, 2008 2:45 pm ]
Post subject:  RE:ID for keys in number pad

you should probably check the same page of documentation as where you found KEY_KEYPAD_5

If you check the value of the constant, it would probably give you a clue as to what the others are as well.

A fairly good guess would be that characters '1', '2', '3', etc. would work.

Author:  isaiahk9 [ Sun May 11, 2008 3:07 pm ]
Post subject:  RE:ID for keys in number pad

No Tony, I checked the page and it gives no clues as to what the other number-pads are. As well, I tried KEY_KEYPAD_1, etc. Doesn't work.

Author:  Tony [ Sun May 11, 2008 4:18 pm ]
Post subject:  RE:ID for keys in number pad

what's the value of KEY_KEYPAD_5 ? (actually I honestly don't know)
Turing:

put KEY_KEYPAD_5


and what about trying Input.KeyDown('1') ?

Author:  jinjin [ Sun May 11, 2008 4:29 pm ]
Post subject:  Re: ID for keys in number pad

Check this program out for all IDs:

Turing:

%% Credits to shorthair
setscreen("noecho")
var inkey : string (1)
loop
    getch (inkey)
    put ord (inkey)
    exit when ord (inkey) = 27
end loop


Credits to shorthair. Original post here:
http://compsci.ca/v3/viewtopic.php?t=3130&highlight=ord

Author:  isaiahk9 [ Sun May 11, 2008 5:11 pm ]
Post subject:  RE:ID for keys in number pad

To Tony : My game is a two-player fighter, and one player has WASD, YUIHJK for controls. PLayer two has the arrows and Num Pad 1, 2, 3, 4, 5, 6.
To jinjin : what do these IDs help with Input.KeyDown?

Author:  Tony [ Sun May 11, 2008 5:22 pm ]
Post subject:  RE:ID for keys in number pad

that doesn't answer either of my questions.

Author:  isaiahk9 [ Sun May 11, 2008 5:43 pm ]
Post subject:  RE:ID for keys in number pad

To Tony :
"what's the value of KEY_KEYPAD_5 ? (actually I honestly don't know) "
I thought you meant what was the point of having that as a key in my game.
"put KEY_KEYPAD_5 "
It just outputs a period.
"and what about trying Input.KeyDown('1')"
I just get this error : Non variable passed to 'var' formal

Author:  S_Grimm [ Mon May 12, 2008 11:30 am ]
Post subject:  RE:ID for keys in number pad

is your numlock on or off? try it with both.

Author:  isaiahk9 [ Mon May 12, 2008 12:45 pm ]
Post subject:  RE:ID for keys in number pad

Still no luck

Author:  Tony [ Mon May 12, 2008 12:54 pm ]
Post subject:  Re: RE:ID for keys in number pad

isaiahk9 @ Sun May 11, 2008 5:43 pm wrote:
I just get this error : Non variable passed to 'var' formal

I'm pretty sure that's not how Input.KeyDown works
Turing:

var chars : array char of boolean
loop
   Input.KeyDown (chars)
   if chars ('1') then
      put "omg, it's 1!"
      delay(5000)
   end if
end loop

Author:  isaiahk9 [ Mon May 12, 2008 1:21 pm ]
Post subject:  RE:ID for keys in number pad

nice, tony. thanx, everybody. What tony said was right - ('1'), and all the others. My buddy pointed that out two minutes after I read Ton'y post. Now, so long as the other player doesn't cheat by pressing number lock or any of the keys above their controls . . .


: