Alt code

From Wikipedia, the free encyclopedia
  (Redirected from Windows Alt codes)
Jump to navigation Jump to search
Illustration showing the sequence of keys to press to enter the Alt code 161, producing the character í (Latin letter i with acute accent). The Alt key is held down while entering the digits on the numeric keypad.

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 Alt 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[edit]

On IBM PC compatible personal computers from the 1980s, the BIOS allowed the user to hold down the Alt key and type a decimal number on the keypad. It would place the corresponding code into the keyboard buffer so that it would look (almost) 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.[a].

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 (as well as changing the display of any previously-entered text in the same manner). A common choice in locales using variants of the Latin alphabet was CP850, which provided more Latin character variants. (There were, however, many more code pages; for a more complete list, see code page).

PC keyboards designed for non-English use included other methods of inserting these characters, such as national keyboard layouts, the AltGr key and/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 (such as later versions of MS-DOS and Windows) 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 (first one non-zero) would attempt to translate the code from the 8-bit OEM code page (for example, CP850) to a matching glyph in the ANSI code page.[b] A leading zero (0) and then a number would produce the character directly from the newer ANSI code page.

For instance, the combination Alt+161 would result in í (Latin letter i with acute accent) which is at 161 in the OEM code page of CP437 or CP850, while Alt+0161 yields the character ¡ (inverted exclamation) which is at 161 in CP1252.[c]. Attempting to type a code in the OEM page that did not exist in the ANSI code page did nothing.[citation needed] The transition to Unicode improved this, as all the codes in both pages exist in Unicode, so they all work.

Transition to Unicode[edit]

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. Although CP1252 is almost identical to the start of Unicode, this prevents entry of the code points from U+0080 to U+009F, and (more problematic) other ANSI code pages prevent entry of some very common Latin accented letters. In addition, much Unicode documentation and the Character Map accessory show the code points in hex, not decimal. So a third method was developed to unambiguously enter Unicode. To enable it a user must set or create the registry key HKCU\Control Panel\Input Method\EnableHexNumpad with type REG_SZ to value 1 and reboot or log out/in.[citation needed][needs update] A leading '+' then allows entry of a hex Unicode value (using the main keyboard for AF), for example Alt++11B will produce ě (e with caron).

Problems[edit]

If Num lock is disabled, attempting an Alt code may cause unexpected results in some applications, due to the controls used on the same key. For example, Alt+4 can be taken as Alt+, 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 (typically labelled "Fn"); thus one must press and hold both Alt and Fn keys while entering the character code. Alternatively, enabling the 'extended' keyboard mappings above (using 'settings', 'control panel' or similar) will meet the needs of most users.

Linux[edit]

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:

  • Hold down Ctrl+⇧ Shift and type U followed by up to eight hexadecimal digits corresponding to the character to be inserted (on main keyboard or numpad), then release Ctrl+⇧ Shift.
  • Type Ctrl+⇧ Shift+U, then type up to eight hexadecimal digits corresponding to the character to be inserted, and then type ↵ Enter.

In OpenOffice.org and Inkscape, for example, only the second method works. In GTK and Firefox and Chrome all methods work.

See also[edit]

Notes[edit]

  1. ^ See article CP437 for a list of the numbers accepted
  2. ^ Simplifying a bit by not taking 16-bit DBCS code pages into account here.
  3. ^ See CP1252 for a list of these zero-prefixed alt combinations

References[edit]

External links[edit]