Mac Forums

Mac Forums (
-   OS X - Development and Darwin (
-   -   [cocoa keyboardInput] (

Three 06-01-2007 09:29 PM

[cocoa keyboardInput]
I am stuck right now on how to capture the arrow keys.I could just use the key codes but the documentation says they are hardware specific.

According to the docs.

Note that some function keys are handled at a lower level and are never seen by your application...
The Arrow keys are considered function keys from what I gather because,

if ([anEvent modifierFlags] & NSFunctionKeyMask ) {

will ring TRUE when the arrow keys create an event. I could use a clue as to how I can then test for the constants "NSUpArrowFunctionKey" and his partners?
Every test I have tried so far ring TRUE.

Three 06-03-2007 10:28 AM

Not to bump the post but:
Just in case anyone is interested. I have found one way. You can load the StandardKeyBinding.dict dictionary file and check the key-value using the return from [anEvent characters] as the key.


- (void)keyDown:(NSEvent *)anEvent
        if ([anEvent modifierFlags] & NSFunctionKeyMask) {
                if ([[keyBindings objectForKey:[anEvent characters]] isEqual:@"moveLeft:"]) {
                if ([[keyBindings objectForKey:[anEvent characters]] isEqual:@"moveRight:"]) {
                if ([[keyBindings objectForKey:[anEvent characters]] isEqual:@"moveDown:"]) {
                if ([[keyBindings objectForKey:[anEvent characters]] isEqual:@"moveUp:"]) {

If anyone knows a better way, for that matter any other way, please let me know.

All times are GMT -4. The time now is 08:38 AM.

Powered by vBulletin
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.