Any Key Pressed Test

Hi,

Is there an easy way to see if any key at all is pressed without
testing each individual key in the array returned by SDL_GetKeyState??

Thanks in advance,
Roy Pluschke

Hi,

Is there an easy way to see if any key at all is pressed without
testing each individual key in the array returned by SDL_GetKeyState??

while(SDL_PollEvent(&event)) {
if(event.type == SDL_KEYDOWN) a_key_is_pressed();
}

Kentarou FukuchiFrom: rjplus@sunshine.net (Roy Pluschke)
Subject: [SDL] Any Key Pressed Test
Date: Fri, 17 May 2002 20:10:49 -0700

Is there an easy way to see if any key at all is pressed without
testing each individual key in the array returned by SDL_GetKeyState??

while(SDL_PollEvent(&event)) {
if(event.type == SDL_KEYDOWN) a_key_is_pressed();
}

Kentarou I think I have not written my question clearly enough. If I
push a key down a SDL_KEYDOWN event is generated as you have shown
above, now if I keep the key depressed no further events are generated.
I do not want to enable key repeat as it effects my fps and I don’t
poll all the time since this is not cpu friendly. The SDL_GetKeyState
lets me test the state of individual keys by inspecting the returned
array. I was hoping there was a “Is user touching keyboard?” function
without having to test all the individual keys in the array.

Thanks,
Roy PluschkeOn Sat, 18 May 2002 19:49:40 +0900 (JST) Kentarou Fukuchi wrote:

Is there an easy way to see if any key at all is pressed without
testing each individual key in the array returned by SDL_GetKeyState??

while(SDL_PollEvent(&event)) {
if(event.type == SDL_KEYDOWN) a_key_is_pressed();
}

Kentarou I think I have not written my question clearly enough. If I
push a key down a SDL_KEYDOWN event is generated as you have shown
above, now if I keep the key depressed no further events are generated.
I do not want to enable key repeat as it effects my fps and I don’t
poll all the time since this is not cpu friendly. The SDL_GetKeyState
lets me test the state of individual keys by inspecting the returned
array. I was hoping there was a “Is user touching keyboard?” function
without having to test all the individual keys in the array.
I guess you could just increment a counter everytime you get a SDL_KEYDOWN
event and decrement that counter when you get a SDL_KEYUP event. If that
counter is >0, that means a key is pressed…

-Ga?tan.