Snippet: Handling Key Clicks in a Custom Keyboard

In a custom keyboard or input accessory you may want to support audio feedback or, as they say on the street, key clicks.

The code snippet below summarizes how to do this:

// Adopt the UIInputViewAudioFeedback protocol
@interface CustomKeyboardAccessoryView : UIView< UIInputViewAudioFeedback> {

}
...
@end

// Implement protocol
- (BOOL)enableInputClicksWhenVisible
{ 
    return YES;
}

// When you should click call 
[[UIDevice currentDevice] playInputClick];

Reference
Text, Web and Editing Programming Guide for iOS: Playing Input Clicks

About idz

A professional software engineer dabbling in iOS app development.
This entry was posted in Code Snippets and tagged , , . Bookmark the permalink.

Leave a Reply