Alt code


On personal computers with numeric keypads that use Microsoft operating systems, such as Windows, many characters that do not have a dedicated key combination on the keyboard may nevertheless be entered using the Alt code. This is done by pressing and holding the key, then typing a number on the keyboard's numeric keypad that identifies the character and then releasing.

MS-DOS

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 an 8-bit character from the current code page that was inserted into the text the user was typing. On the original IBM PC the code page 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. This input method is emulated by many pieces of software that do not use the BIOS keyboard decoding.
In the ASCII standard, the numbers 0-31 and 127 are assigned to control characters, for instance, code point 7 is typed by. While some applications would insert a bullet character , some would treat this identical to which often was a command for the program.

Windows

The Alt codes had become so well known and memorized by users that Microsoft decided to preserve them in Microsoft Windows, even though the OS features a newer and different set of code pages such as CP1252. Windows includes the following processing algorithm for Alt code, which supports both methods:
  • The familiar + combination retains the old MS-DOS behavior, i.e., generates characters from the legacy code pages now called "OEM code pages". For instance + produces. code point 163 in CP437 or CP850. The "OEM code page" selection served little or no other purpose other than to control what Alt codes produced, if other code pages were selected then these numbers could produce different characters, but it did not change the display. It was impossible to type characters that were not in the Windows code page, such as box-drawing symbols.
  • The new + combination, produces characters from the newer "ANSI code pages". For instance + results in . The active Windows code page could be different, which could change the effect of these Alt codes.

    Unicode

Later versions of Windows and applications such as Microsoft Word supported Unicode. As Unicode included all the characters in all the MSDOS code pages, this had the immediate benefit that all the old MSDOS Alt combinations worked, not just the ones that existed in the Windows Code Page. And far more software stopped changing how documents displayed or printed when the selected code page was changed.
In the IBM PC Bios typing an Alt code greater than 255 produced the same as that number modulo 256. Some applications retained this behavior, while others made numbers from 256 to 65,535 produce the corresponding Unicode character. For instance, + in WordPad produces the. If the Windows Code Page was set to CP1252 then all Unicode BMP characters except control characters could be typed this way.

Hex Alt Codes

Because most Unicode documentation and character tables show the code points in hex, not decimal, a variation of Alt codes was developed to allow the typing of numbers in hex. 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, assign the value data 1 to it, and then reboot or log out/in. A leading then indicates hex input, for example will produce .
There are many other ways of typing arbitrary Unicode characters, such as the Character Map utility.

Other operating systems

The Alt key method does not work on ChromeOS, macOS, Linux or other operating systems and there is no evidence of interest in replicating it. However, numeric entry of Unicode characters is possible in most Unix or Unix-like OSs by pressing and releasing, and typing the hex number followed by the space bar or enter key. For example,
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.

List of codes