Alt code


On personal computers using Microsoft operating systems, characters that do not have a dedicated key may nevertheless be entered using the Alt numpad input method or Alt code. This is done by pressing and holding the key while typing a number that identifies the character, using the keyboard's numeric keypad. Similar or extended forms of this feature are also available in some other operating systems.
Often this is the best or only method many computer users know for entering non-ASCII characters. Many Wikipedia articles on various characters will include how to type that character using Alt codes for code page 437.

History and description

On IBM PC compatible personal computers from the 1980s, the BIOS allowed the user to hold down the key and type a decimal number on the keypad. It would place the corresponding code into the keyboard buffer so that it would look as if the code had been entered by a single keystroke. Applications reading keystrokes from the BIOS would behave according to what action they associate with that code. Some would interpret the code as a command, but often it would be interpreted as a code to be placed on the screen at the location of the cursor, thus displaying the corresponding 8-bit character from the current code page. On the original IBM PC this was CP437..
Some Eastern European, Arabic and Asian computers used other hardware code pages, and MS-DOS was able to switch between them at runtime with commands like KEYB, CHCP or MODE. This causes the Alt combinations to produce different characters. A common choice in locales using variants of the Latin alphabet was CP850, which provided more Latin character variants..
PC keyboards designed for non-English use included other methods of inserting these characters, such as national keyboard layouts, the AltGr key or dead keys, but the Alt key was the only method of inserting some characters, and the only method that was the same on all machines, so it remained very popular and often the only scheme a user knew for entering some letters.
This input method is emulated by many pieces of software that do not use the BIOS keyboard decoding. The CP437/CP850 numbers became so well known and memorized by users that Microsoft decided to preserve them, even though it used a new and different set of code pages for Windows such as CP1252. These new code pages were called ANSI code pages by Microsoft, while the old ones were called OEM code pages. Holding Alt and typing three digits would attempt to translate the code from the 8-bit OEM code page to a matching glyph in the ANSI code page. A leading zero and then a number would produce the character directly from the newer ANSI code page.
For instance, the combination + would result in which is at 161 in the OEM code page of CP437 or CP850, while + yields the character which is at 161 in CP1252.. Attempting to type a code in the OEM page that did not exist in the ANSI code page did nothing. The transition to Unicode improved this, as all the codes in both pages exist in Unicode, so they all work.

Transition to Unicode

When Windows later transitioned to Unicode, there was a desire to extend the Alt code technique to allow entry of any Unicode code point. Some applications like Word 2010 or PSPad 4.5.6 interpret alt codes larger than 255 directly as a decimal Unicode code point, but other software interprets such numbers modulus 256, or ignores any digits after the third. As numbers less than 256 use the ANSI code page, it is impossible to enter the code points from U+0080 to U+009F, and if the code page is not cp1252 then some very common Latin accented letters cannot be entered. In addition, much Unicode documentation and the Character Map accessory show the code points in hex, not decimal.
Therefore a third method was developed to unambiguously enter Unicode. To enable it a user must set or create a string type value called EnableHexNumpad in the registry key HKEY_CURRENT_USER\Control Panel\Input Method and assign the value data 1 to it and then reboot or log out/in. A leading '+' then allows entry of a hex Unicode value, for example + will produce .

Problems

If is disabled, attempting an Alt code may cause unexpected results in some applications, due to the controls used on the same key. For example, can be taken as, causing a web browser to go back one page.
Many laptops do not have a separate numeric keypad, but some may provide numpad input by holding a modifier key ; thus one must press and hold both and keys while entering the character code. Alternatively, enabling the 'extended' keyboard mappings above will meet the needs of most users.

Linux

The Alt key method does not work on Linux systems and there seems to be little interest in replicating it, due to it including the dated IBM PC character encoding as part of its definition. However, numeric entry of Unicode characters is possible and it is done by the application or the UI toolkit library. This entry method has been somewhat standardized though there are slight variations:
In OpenOffice.org and Inkscape, for example, only the second method works. In GTK and Firefox and Chrome all methods work.