Recently I bought a new keyboard (see below) on Amazon for Macbook pro. I needed another cheaper keyboard when I might use it with wall mounted monitor near a tread mill. It is a knock off of Mac’s magic keyboard. Interestingly it has both bluetooth and wireless (2.4G) connectivity while having all the four keys Fn, Ctrl, Option and Cmd keys in the same order. Many of the third party mac keyboards either miss Fn key or place it near number keys and many other place them in Windows compatible keyboard order which is not ideal.
This keyboard worked well but for one major issue – Esc key didn’t act the way one expected. Nothing was happening and in “Vim” editor it is one of the most often used key. I needed to either fix or identify the right key code it is generating or map it to new code or return the item. I knew what ascii code (dec. 27) and key code (53) I should expect on pressing the key. Here are the corresponding codes.
And the mac key codes. (Credit: eastmanreference.com)
After downloading an utility app called Key Codes from Many Tricks, I validated the codes and found it was Fn+Esc key on the keyboard that was generating the correct code. See below for the output after pressing keys “a”, “1”, “Space bar”, “Fn+Esc”, “Cmd+C”. Instead of modifying the key mapping which created its own issue I decided to use for now Fn+Esc key. Pressing just any modifier key doesn’t generate key code but in combination with other keys, for example, Cmd+C the modifier affects the key code.