Capturing Arrow Key Press

robmcq
Unregistered
 
Post: #1
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
Quote this message in a reply
Member
Posts: 40
Joined: 2004.12
Post: #2
Try this from apple's site.

Look in the constants section under keys.

Jericho
Quote this message in a reply
Member
Posts: 196
Joined: 2003.10
Post: #3
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.
Quote this message in a reply
Moderator
Posts: 508
Joined: 2002.09
Post: #4
try [event charactersIgnoringModifiers] which returns an NSString.

event is an NSEvent that you get from the keyDown method

"When you dream, there are no rules..."
Quote this message in a reply
Member
Posts: 114
Joined: 2005.03
Post: #5
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.
Quote this message in a reply
Member
Posts: 304
Joined: 2002.04
Post: #6
int keyCharacter = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
if (keyCharacter == NSUpArrowFunctionKey) .... ;
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Spaces on Snow Leopard and ctrl/arrow keys GolfHacker 19 15,970 Dec 4, 2012 03:18 PM
Last Post: bmantzey
  Suggestions on capturing video from opengl app? m3the01 19 7,457 Aug 23, 2008 02:01 PM
Last Post: AnotherJake
  Handling more than one key press at once wyrmmage 7 4,495 Sep 17, 2006 03:52 PM
Last Post: wyrmmage
  Capturing Kestrokes honkFactory 2 3,168 Jan 27, 2003 04:30 PM
Last Post: OneSadCookie