Learn how to remove, swap, replace, repair and clean the keys on your iMac, Mac or MacBook laptop, with our simple Mac keyboard repair guide. Plus: how to swap key functions around using Mac OS X and free Mac tools.

How do I remove keys from my Mac keyboard, then replace them afterwards? I want to get underneath to clean up a coffee spill. I might as well replace the dirty and damaged keys while I'm at it.

Moving and replacing keys on a Mac can be split into two categories. First, you may want to know how to physically move the hardware keys around on your Mac keyboard (to change a US keyboard layout into a UK keyboard layout, for example, to replace a damaged Spacebar with a new replacement or to access the innards to more effectively clear up a liquid spill). Second, you may want to use your Mac's OS settings to swap the functions of one key on to another key location on the keyboard.

Whether you want to know how to physically move, remove and replace keys on the keyboard of your iMac, Mac Pro, MacBook Pro or MacBook Air, or just remap the functions of Mac keys, we explain the process in this article.

See also: What and where is the Option key on a Mac?

iPhone repair tool

This is the tool we're going to use to remove the keys from our iMac keyboard. It's plastic, crucially, and has a slender flat end and offers good leverage. It was sold to us as part of an 'iPhone repair kit', but similar items are available from electronics shops, hobby stores and online

Desktop Mac reviews | MacBook reviews

How to physically remove the keys from a Mac or MacBook keyboard

Unlike in most situations, Macs are distinctly less user-friendly than PCs when it comes to tinkering: Apple is quite openly unhappy about the idea of you making physical upgrades to its MacBooks and desktop Macs. And Mac keyboards are no exception, which may be why you had to look for help online.

Current and recent Apple keyboards have low keys, which gives them a classy feel and a nice typing action but makes it tricky to get under the key and prise it out, particularly without damaging the 'scissor lift' mechanism underneath. So be very careful in the way you dislodge the unwanted/incorrectly positioned keys.

You need a flat probe or tool, but it's best if it's plastic or a similar material rather than metal, which rules out most screwdrivers. (Metal is more likely to cause damage.) A wiring tool called a 'spudger' is about right; a nail file could also work well.

Slide your chosen tool very gently under the edge of the key and lever it up slowly until the key lifts up and detaches. The precise mechanism will depend on which model of keyboard you've got, but there should be a small plastic assembly (which you need to be careful about damaging while detaching the key) and a little rubber nubbin in the centre. Don't remove these.

Here's how to remove an iMac keyboard key: gently and slowly, using our neat little iPhone tool. Please excuse the long girlish fingernails

And here's what happens when you lever too hard. Luckily the F19 key landed on a colleague's desk, but it's incredibly easy (and frustrating) to lose them

How to remove iMac keyboard keys

This is what it looks like under our F19 key. Note the plastic scissor lift frame and the small rubber nubbin in the centre

How to remove iMac keyboard keys

Here we've raised the key mechanism so you can see how it works

How to clean up liquid spills and other dirt and mess under Mac keys

The space you've now opened up is delicate, but can be cleaned out safely. A cotton wool bud or similar soft-ended tool is ideal for soaking up small liquid deposits and lifting out detritus. Make sure you don't stress the delicate plastic of the scissor-lift mechanism.

How to install extra RAM memory in the new iMac

How to replace keys on a Mac or MacBook keyboard

Now we'll run the process in reverse. Line up the key over the empty slot where you want it, with the four small plastic nodules over the two holes and the wide gap over the long bar. (You'll only need these directions if it's a blank key like a Spacebar, of course - usually you can just make sure the letter or number isn't upside-down!)

How to remove iMac keyboard keys

Press down gently but firmly until you feel a little click, and the key is re-attached. Test it out a few times to make sure the connection is sound and the action clear.

How remap/swap the functions of keys on a Mac or MacBook keyboard

Now we're back into the realm of software changes, the Mac becomes user-friendly once more. Most of the time the Mac will detect the keyboard you've attached automatically, and offer the correct keyboard layout.

However, if you've done as we did previously and rearranged the keys yourself - say you're bought a nice US keyboard, but wanted to set up the keys in a UK configuration - the OS still views your keyboard in its old, unchanged setup. How do we force Mac OS X to think differently?

Go to System Preferences and click Keyboard, then Change Keyboard Type…

At this point Mac OS X may try to go through its standard keyboard detection process, then tell you it can't identify the keyboard. Just click Continue, then press the key next to Shift when prompted. Then press Skip. Finally, Mac OS X lets you choose between the three main keyboard layout types: Japanese, European and United States.

There are more options available than that, of course. Go to System Preferences, Language & Text (this may be labelled as International in some older versions of Mac OS X) and Input Sources (or Input Menu). If you want to use a Polish keyboard layout, say, scroll down the list on the left and tick Polish, then scroll back up and untick British.

Mac international keyboard input sources

Now when we type the top row of letters it comes out as qwertzuiop. (The Polish layout swaps the Y and Z, as well as the full stop and comma.)

It's possible to add keyboard layouts to the options here - have a look around for ones that catch your fancy. This fairly old one is good for making the UK Apple keyboard map back to a non-Apple UK keyboard.

If you want to get more involved than that (ie if you want to create your own custom key layout) you'll need a bit of third-party software, although free options are available: Ukelele is one that's worth a try.

Follow David Price on Twitter | Follow Macworld UK on Twitter

See also:

iMac reviews | Mac mini reviews | Mac Pro reviews | MacBook Air reviews | MacBook Pro reviews

How to get more space on your Mac

How to recover your Mac from a back up