keyboard
prudencius

How can i catch a key up event?

thanks

Kikaru

Explain what you mean by "key up."

Steve Terry

if(!key[KEY_BLAH])

Dustin Dettmer
GetKeyAsync()

Audric

To elaborate on the "if(!key[KEY_BLAH])" :

1char old_key[KEY_MAX];
2// on startup
3for (int i=0; i < KEY_MAX; i++)
4 old_key<i> = key<i>;
5 
6// Now call this 50 times a second or more, so you
7// don't miss an event:
8for (int i=0; i < KEY_MAX; i++)
9{
10 if (key<i> && ! old_key<i>)
11 {
12 // handle "key on" here
13 //
14 }
15 else if (! key<i> && old_key<i>)
16 {
17 // handle "key off" here
18 //
19 }
20 old_key<i>=key<i>;
21}

Steve++
Thread #587351. Printed from Allegro.cc