How to read USB keyboard key codes with multimedia keys

Is it possible to read non-standard key key codes using the special iOS API or through the general TextInput field? I have a multimedia keyboard with special buttons, and I want my iPad app to learn about these key codes.

I know that iOS can use some of them already (i.e. volume up / down, next / previous track).

+5
source share
1 answer

You might want to try subclassing UIApplication and overriding sendEvent:it to find out what events are going on there. Given that UIEvent does not document support for keyboard events in iOS (unlike NSEvent in AppKit), I am skeptical that you will see keyboard events ... but it's worth a try. I don't have a BT keyboard to try it myself.

To use the UIApplication subclass, edit main.mand pass your subclass as the third argument to UIApplicationMain:

int main(int argc, char *argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, YourApplicationSubclass, nil);
    [pool release];
    return retVal;
}

This strategy is not uncommon for Cocoa desktop applications, and is also explained here:

http://cocoawithlove.com/2009/05/intercepting-status-bar-touches-on.html

+1
source

All Articles