Is there a way to programmatically invoke the keypad "click" sound? My app has a custom keypad (built out of UIButtons) and I'd like to provide some audio feedback when the user taps on the keys. I tried creating my own sounds in Garageband, but wasn't happy with any of my creations. If there isn't a standard way to invoke the key click, can anyone point me to a library of sounds that might have such a gem?
10 Answers
There is a really fast solution to play the default keyboard sound:
Add AudioToolbox.framework
Add the following line wherever you want the sound to play:
AudioServicesPlaySystemSound(0x450);

- 1
- 1

- 321
- 3
- 2
-
This a great way to play any sound in the toolbox. – ocodo Dec 12 '12 at 05:12
-
Doesn't seem to work for me, on iOS 7. Not sure if the ids have changed or if it's some other issue. – Kenny Winker Feb 20 '14 at 19:00
-
ID changed. Try AudioServicesPlaySystemSound(1104);. – Reuben Scratton Nov 15 '15 at 12:52
-
FYI: 0x450 (hex) is 1104 (decimal); same ID's. – geowar Feb 14 '16 at 17:43
As of iOS 4.2, adopt the UIInputViewAudioFeedback protocol on a custom subclass of UIView. Make this view your "inputView" and then call "playInputClick" at the appropriate time.
Just to save some people time. Put this in your custom view:
- (BOOL) enableInputClicksWhenVisible {
return YES;
}
To make the click do this:
[[UIDevice currentDevice] playInputClick];
-
1This seems like the right way to do it, as it will respect the user's global setting for keyboard click sounds. But it doesn't seem to work. Has anyone implemented this method successfully? – Christopher Pickslay Mar 03 '11 at 21:56
-
3This works perfectly fine for me however it has a catch, it only works if the keyboard is visible... It's perfect for what it's intended for which is accessory views and alternate input views for textviews and textfields, but it's not a solution if you want to simply play the sound anywhere any time. – ima747 Feb 17 '12 at 18:58
-
Brilliant! This is the proper way to do it for an accessory view on the keyboard. I had never seen this mentioned before. – David H Oct 26 '13 at 13:25
-
Check out this sample implementation here: https://stackoverflow.com/a/39385287/1306012 – Bruno Bieri Jan 07 '22 at 16:22
No need to copy the file into your own app - you should be able to get it directly from the UIKit framework:
CFURLRef soundFileURLRef = CFBundleCopyResourceURL(
CFBundleGetBundleWithIdentifier(CFSTR("com.apple.UIKit")),
CFSTR ("Tock"),CFSTR ("aiff"),NULL);
-
1how do you put this into the code? I tried AudioServicesCreateSystemSoundID(soundFileURLRef) but it throws an error... – jowie Aug 23 '10 at 16:43
This is what I made out of it aSquared's comment:
NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.UIKit"] pathForResource:@"Tock" ofType:@"aiff"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID);
AudioServicesPlaySystemSound(soundID);
AudioServicesDisposeSystemSoundID(soundID);

- 7,282
- 2
- 41
- 71
Using 0x450 as the SystemSoundID works for me (and at the correct volume - just playing the built-in Tock.aiff was too loud). No idea how portable that is - this is on an iPod Touch 3rd gen.
Still doesn't respect the preference for tick on/off.

- 654
- 4
- 9
-
Thank you, this works perfect. Please post the same answer to http://stackoverflow.com/questions/1513986/how-to-get-iphone-os-3-1-muffled-keyboard-sound/1563097#1563097 so I can give the bounty to you (you deserve it most). – MrMage Oct 14 '09 at 11:00
The simplest way I've found is to extract Tock.aiff (the keyboard sound) from the iPhone Simulator and package it with your app, then play it using AudioServicesPlaySystemSound()
at the appropriate time. On my machine, simply typing Tock.aiff into Spotlight turns up the file, but if you have to go looking for it, it's in the simulator version of UIKit.framework.

- 17,541
- 7
- 56
- 91
-
1I had actually done this with "Tock.caf" from the Metronome example for testing purposes, but was reluctant to include it in the finished product for fear of copyright issues. Is this "allowed"? – George Armhold May 04 '09 at 13:45
-
1From my reading of the iPhone developer license agreement (disclaimer: I'm not a lawyer), you can't use Tock.aiff unless you can find it as part of sample code or an open source component (section 2.6). – outis May 04 '09 at 20:34
-
It's not clear that it's technically legal, but I've done it in two apps now and not gotten any complaints. Perhaps Apple is actually willing to be reasonable about something for once. If not, there may be a way to use the copy already on the iPhone, but that seems susceptible to breaking if Apple removes the sound. – Becca Royal-Gordon May 04 '09 at 21:24
-
It is definitely available in sample code- check out the Metronome example. It includes both "tick" and "tock" soundfiles, though I am not sure that these are the same sound that "the system" actually uses. – George Armhold May 04 '09 at 21:40
-
4Keep in mind that this will ignore the users preference to disable the keyboard sound. – Jason Harwig Jul 06 '09 at 17:09
-
Wow I've been looking for this sound for over an hour all over Google while it was gently sitting on my HD. Thank you!! – samvermette Nov 19 '10 at 22:46
Here's what I did:
Locate 'Tock.aiff' in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/System/Library/Frameworks/UIKit.framework
Drag it into your Resources folder in xCode, ticking 'Copy items into destination group's folder'
Import AVFoundation.framework into the Frameworks folder in xCode
Import AVFoundation at the top of your class:
#import <AVFoundation/AVAudioPlayer.h>
Use the following function:
- (void)PlayClick {
NSURL* musicFile = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"Tock"
ofType:@"aiff"]];
AVAudioPlayer *click = [[AVAudioPlayer alloc] initWithContentsOfURL:musicFile error:nil];
[click setVolume:0.15f];
[click play];
}
That's it!

- 4,467
- 6
- 34
- 48
From what I can tell, the click sound isn't available to apps. I haven't seen anything in audio session services that is relevant. AudioServicesPlaySystemSound()
looks promising, but there doesn't appear to be any system sound ID for the click sound (a closer look at the headers may turn up something). You could always loop over a call to AudioServicesPlaySystemSound(i)
and see if anything plays. The iPhone software restore images probably have the sound, but it's probably not licensed for general use. Jailbreaking an iPhone to get at the tasty click sound doesn't need to be mentioned.
For (creative commons) sounds, check out the Freesound Project.
For the future, perhaps request that Apple expose system sounds other than the alert sound for use with AudioServicesPlaySystemSound()
.

- 75,655
- 22
- 151
- 221
Maybe a bit late ...
But in MrMage last post, if you do AudioServicesDisposeSystemSoundID(soundID);
straight after AudioServicesPlaySystemSound(soundID);
then you won't hear a thing as you're discarding the system sound right after creating it.
You have to let it finish playing first.. Only call AudioServicesDisposeSystemSoundID to cancel the sound before it finishes

- 2,142
- 1
- 26
- 35
-
Playing a system sound really makes my interface animation slow down. Are there any quicker ways? – jowie Aug 23 '10 at 16:56
-
You can play sound in a 2nd thread instead. Use NSOperationQueue to start a task in a 2nd thread. And start the sound there instead – jyavenard Sep 17 '10 at 09:03
You do not have to dispose of the sound object right away. Keep a pointer to that sound object in a property, and dispose of it only when you are about to play another sound before re-creating it.
And of course finally dispose of the SystemSoundID object in dealloc.

- 2,142
- 1
- 26
- 35