Correct way of handling key down
arekkusu Wrote:Has anyone noticed this bug's revival in 10.3.7? Some apps stop responding to keyboard input here after using the system for a while...Funny you should mention that... I noticed that it had returned just the other day (although I'm still using 10.3.6). It took me a while to figure out what the problem was: the Terminal app. Quit it and everything returns to normal.
This may just be something peculiar to my machine, though. Several other people who tried the same thing said that it didn't happen for them.
Hm... I have had Terminal open every time it's occurred. I'll try that next time it happens.
I used to be able to log in to an app called Aquamon and then log back out and the keys would come back. I don't know if this is the same case since I haven't had the key problem in a year or two.
It appears to be due to Terminal's "Secure Keyboard Entry" feature-- when active, GetKeys() is disabled globally which breaks some games etc.
So, Terminal can stay running, just don't use secure entry.
So, Terminal can stay running, just don't use secure entry.
Hm, I get a 404 on that server. Nevertheless, very interesting information. Thanks for digging it out!
The main reason to pool for keyboard input with GetKeys(), instead of using the standard key events, is to check whether a "modifier key" (such as shift or control) is being held down. This is needed because modifier keys don't generate key events when they are pressed. For instance, If you wanted to make a character jump when shift is pressed, you would have to use GetKeys() in a polling loop. Hope this helps!
You can use the Carbon Event kEventClassKeyboard/kEventRawKeyModifiersChanged to be notified when the modifiers change. No polling necessary.
- Alex Diener
- Alex Diener
arekkusu Wrote:It appears to be due to Terminal's "Secure Keyboard Entry" feature-- when active, GetKeys() is disabled globally which breaks some games etc.Thanks for tracking that information down! I had indeed turned on Secure Keyboard Entry for the reason Rentzsch mentions in his article ("Don't I want my keyboard entry to be secure all the time?"). Turning it off does fix the problem.
So, Terminal can stay running, just don't use secure entry.
spaceb Wrote:This is needed because modifier keys don't generate key events when they are pressed.They certainly do. What do you think [NSResponder flagsChanged:] is for?
There's no need to poll. Don't do it, it just wastes CPU and makes me angry.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| NSWindow frame message not returning correct values after moving the window | Svarog | 6 | 4,180 |
Jan 7, 2007 06:41 PM Last Post: OneSadCookie |
|
| CB Key handling | skyhawk | 6 | 3,193 |
Aug 12, 2003 10:13 AM Last Post: kelvin |
|

