Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » keyboard

This thread is locked; no one can reply to it. rss feed Print
keyboard
prudencius
Member #7,452
July 2006

How can i catch a key up event?

thanks

Kikaru
Member #7,616
August 2006
avatar

Explain what you mean by "key up."

Steve Terry
Member #1,989
March 2002
avatar

if(!key[KEY_BLAH])

___________________________________
[ Facebook ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

Dustin Dettmer
Member #3,935
October 2003
avatar

GetKeyAsync()

Audric
Member #907
January 2001

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++
Member #1,816
January 2002

Go to: