Capturing Arrow Key Press
Does anyone know what the structure is for the NSEvent class? I want to capture arrow input for my application. I know that this calls the keyDown and keyUp methods but I don't know anything about the NSEvent class that is passed into these functions. Any help is appriciated.
Rob
Rob
There's a lot of info on that already posted. Try searching.
Hints:
- Use an array of keys to store their states (up, down)
- Operate based on those states. For instance, if you have a ship that's shooting, only shoot if the space bar state is down, and so on.
Hints:
- Use an array of keys to store their states (up, down)
- Operate based on those states. For instance, if you have a ship that's shooting, only shoot if the space bar state is down, and so on.
try [event charactersIgnoringModifiers] which returns an NSString.
event is an NSEvent that you get from the keyDown method
event is an NSEvent that you get from the keyDown method
"When you dream, there are no rules..."
Use the keyCode method, which returns an integer. There's an old, but still correct table somewhere on developer.apple.com that shows what keys map to what key codes. Unfortunately, it's extremely hard to find, so if you can't find it, use an NSLog to show the codes you get when pressing the keys and then use them.
Edit: I found it here. I know it's old, but it worked for me.
Edit: I found it here. I know it's old, but it worked for me.
int keyCharacter = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
if (keyCharacter == NSUpArrowFunctionKey) .... ;
if (keyCharacter == NSUpArrowFunctionKey) .... ;
Possibly Related Threads...
Thread: | Author | Replies: | Views: | Last Post | |
Spaces on Snow Leopard and ctrl/arrow keys | GolfHacker | 19 | 26,737 |
Dec 4, 2012 03:18 PM Last Post: bmantzey |
|
Suggestions on capturing video from opengl app? | m3the01 | 19 | 11,734 |
Aug 23, 2008 02:01 PM Last Post: AnotherJake |
|
Handling more than one key press at once | wyrmmage | 7 | 6,664 |
Sep 17, 2006 03:52 PM Last Post: wyrmmage |
|
Capturing Kestrokes | honkFactory | 2 | 4,340 |
Jan 27, 2003 04:30 PM Last Post: OneSadCookie |