views:

272

answers:

1

There's an action in my program which users need to perform very frequently (potentially hundreds of times per session), and I'd like to add a keyboard shortcut for users with a bluetooth keyboard. Is there any way to do this?

Right now, the closest I've come is triggering the action whenever the U+F8FF character is entered (shift+alt+k on an iPad/iPhone/Mac, which prints an apple logo character) in a text view. Of course, this would present an issue if the user actually wanted to input an apple symbol.

Are there any better ways to support keyboard shortcuts (hopefully command+something, rather than shift+alt+something)? Thanks!

+3  A: 

Under Cocoa for Mac OS X, you would gather modifier key information from the NSEvent passed to the keyDown: method in an NSResponder object. CocoaTouch replaces the NSResponder with UIResponder and NSEvent with UIEvent. The UI versions don't have documented keyboard event support. I'm guessing that Apple has extended UIResponder to handle keydown events, but hasn't publicly documented the changes yet. Unfortunately that means we'll just have to wait for that documentation to be able to read the modifier keys.

I think your current solution is a fine solution until Apple gives us a keyboard supporting UIResponder.

Mr. Berna