Alt code: Difference between revisions

Content deleted Content added
Undid revision 1237364008 by 164.215.214.154 (talk) NO. Make a version that talks about mod-256 *ONCE*. This is ridiculously bloated
Tags: Undo Reverted
m Reverted 1 edit by 37.39.179.168 (talk) to last revision by Spitzak
 
(45 intermediate revisions by 12 users not shown)
Line 1:
{{Short description|MethodInput for entering characters into a computermethod}}
{{More citations needed|date=March 2022}}
 
Line 6:
==MS-DOS==
 
On [[IBM PC compatible]] [[personal computer]]s from the 1980s, the [[BIOS]] allowed the user to hold down the {{keypress|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 an 8-bit character from the current [[code page]] that was inserted into the text the user was typing.<ref name="AltModulo">If the entered value exceeds 255, only the remainder after dividing by 256 (i.e., the value [[modulo]] 256) was used by the BIOS. For example, 520 is interpreted as 520 mod 256 = 8, so it produces the same character as for value 8.</ref> On the original [[IBM PC]] the code page was [[CP437]].
 
Some Eastern European, Arabic and Asian computers used other hardware [[code page]]s, and MS-DOS was able to switch between them at runtime with commands like <code>KEYB</code>, <code>[[List of DOS commands#CHCP|CHCP]]</code> or <code>[[List of DOS commands#MODE|MODE]]</code>. 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{{Crossreference|text=; 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 layout]]s, the [[AltGr key]] or [[dead key]]s, 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.{{where|date=October 2020}}{{clarify|reason = Alt codes worked on on computers set to US layout, and also many characters were still not accessible using AltGr|date=October 2020}} 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.
Line 16:
==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, e.g.,such as [[CP1252]]. Windows includes the following processing algorithm for Alt code, which supports both methods:
 
* The familiar {{key press|Alt}}+{{key press|#}}{{key press|## combination (where}}{{key press|###}} is from 0 to 255)combination retains the old [[MS-DOS]] behavior, i.e., generates characters from the legacy code pages now called "[[Windows code page#OEM code page|OEM code pages]]".<ref name="WindowsAltAlgo" /> For instance, the combination {{key press|Alt}}+{{key press|1}}{{key press|6}}{{key press|3}} would result inproduces {{charunichar|ú00fa}}. (Latincode letterpoint u163 within [[acuteCP437]] accentor [[CP850]]). whichThe is"OEM atcode 163page" inselection theserved OEMlittle or no other purpose other than to control what Alt codes produced, if other code pagepages ofwere CP437selected orthen CP850.<refthese name="WindowsAltAlgo"numbers />could produce different characters, but Thisit did not workchange forthe display. It was impossible to type characters that were not in the Windows Codecode Pagepage, (such as box-drawing characters)symbols.
 
* The new {{key press|Alt}}+{{key press|0}}{{key press|#}}{{key press|#}}{{key press|#}} combination (which prefixes a zero to each Alt code), produces characters from the newer "[[Windows code page#ANSI code page|WindowsANSI code pages]]"."{{efn|Microsoft initially referredacknowledged to them asthat "ANSI" code pages," but later acknowledged that this asis a misnomer.}} Forterm example,and {{keybetter press|Alt}}+{{key press|0}}{{key press|1}}{{key press|6}}{{key press|3}} yields the character {{char|£}} (symbol for the [[pound sterling]]) whichname is at"Windows 163code in CP1252page".}}<ref name="WindowsAltAlgo">{{Cite web |date=2016-07-22 |title=To input characters that are not on your keyboard |url=http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/lang_char_code_input.mspx |url-status=dead |archive-url=https://web.archive.org/web/20160722031546/http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/lang_char_code_input.mspx?mfr=true |archive-date=2016-07-22 |access-date=2022-12-30 |website=Microsoft }}</ref> For instance {{key press|Alt}}+{{key press|0}}{{key press|1}}{{key press|6}}{{key press|3}} results in {{unichar|00a3}} (when [[CP1252]] is active, because it occupies position 163 in that code page). 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 operator|modulo]] 256.<ref name="AltModulo"/><ref name="WannaBuildASnowman">{{Cite web |first=Raymond |last=Chen |title=The history of Alt+number sequences, and why Alt+9731 sometimes gives you a heart and sometimes a snowman |work=The Old New Thing |publisher=Microsoft |date=2 July 2024 |url=https://devblogs.microsoft.com/oldnewthing/20240702-00/?p=109951}}</ref> Some applications retained this behavior, while others (in particular applications using the Windows [[RichEdit]] control, such as [[WordPad]] and [[PSPad]]) made numbers from 256 to 65,535 produce the corresponding Unicode character.<ref name="RichEdit">{{Cite web |last=Walker |first=Jim |display-authors=etal |title=About Rich Edit Controls |work=Windows App Development |publisher=Microsoft |via=[[Microsoft Learn]] |url=https://learn.microsoft.com/windows/win32/controls/about-rich-edit-controls |date=27 April 2022}}</ref> For instance, {{key press|Alt}}+{{key press|9}}{{key press|7}}{{key press|3}}{{key press|1}} in WordPad produces the {{unichar|2603}}. If the Windows Code Page was set to CP1252 then all Unicode BMP characters except [[C0 and C1 control codes|control characters]] could be typed this way.
 
===HexadecimalHex Alt codesCodes===
 
Because most Unicode documentation and the [[Character Map (Windows)|Character Map]]character utilitytables show the code points in [[base 16|hex]], not decimal, a variation of Alt codes was developed to allow the typing of numbers in hex (using the main keyboard for {{keypress|A}}–{{keypress|F}}). To enable it, a user must set or create a string type ({{code|REG_SZ}}) value called <code>EnableHexNumpad</code> in the [[Windows Registry|registry]] key <code>HKEY_CURRENT_USER\Control&nbsp;Panel\Input&nbsp;Method</code>, assign the value data <code>1</code> to it, and then reboot or log out/in. A leading {{keypress|+}} then indicates hex input, for example {{key press|Alt|+}}{{key press|1|1|B|chain=}} will produce {{char|ě}}&nbsp;(e with [[caron]]).
There are many [[Unicode input|other ways]] of typing arbitrary Unicode characters, such as the [[Character Map (Windows)|Character Map]] utility.
 
== Other operating systems ==
Line 38 ⟶ 41:
==Limitations==
If {{key press|[[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, {{keypress|Alt|4}} can be taken as {{keypress|Alt|←}}, causing a web browser to go back one page.
 
Alt codes did not work on some separate numpad devices.{{cn|reason=Sounds like a bug, there is no technical reason this could not work|date=April 2022}}
 
== List of codes ==
Line 733 ⟶ 734:
* [[List of Unicode characters]]
* [[Numeric character reference]]
* [[Unicode input]]
 
==Notes==