9

Firstly, do I have a correct understanding of what these keys do?

On the Wikipedia SysRq page, it says that the Alt key must be held down to invoke SysRq. On the BIOS interrupt call page, it says Shift+Print Screen invokes interrupt 05h. The page about Break says that Ctrl+Break is translated instantly via 1Bh.

From these pages, my understanding is:

Modifier Key Result
(none) Print Screen ???
Shift Print Screen Send screen to the printer
Alt Print Screen System request
(none) Pause Pause
Ctrl Pause Break

It seems a bit odd to me that Print Screen requires Shift to do anything, and that Pause and Print Screen would have the same sort of labelling, but different modifiers for their secondary functions. What's the logic behind this?

5
  • 3
    Since any assignment of keys to reactions involves software, which are you referring to? BIOS, plain old DOS, ancient Linux, ancient Windows, applications? Commented May 24 at 5:34
  • @thebusybee This is BIOS and/or MS/PC-DOS. IBM did some wacky things with the original PC keyboard, despite it basically sending scan codes. Commented May 24 at 5:44
  • @thebusybee I'm referring to the BIOS. Commented May 24 at 5:49
  • 3
    I'm afraid that "logic" seems overrated when we look at historic decisions. Now I'm curious whether there is any reasoning at all... :-D Why do you expect a logic? Commented May 24 at 6:16
  • Shift+<key> output is shown above the plain key label on keyboards. I would expect the front-side labelled keys to also have consistent logic about activating those alternate functions. Commented May 24 at 6:30

2 Answers 2

13

Take a look at the pictures in the Wikipedia article on IBM PC keyboard.

On the original 83-key keyboard:

  • The PrtScr function is Shift and PrtScr *, used to print what is currently on the screen. In DOS, Ctrl and PrtScr * is also used to begin or end having each line displayed on the screen also echoed to the printer.
  • The Break function is Ctrl and Scroll Lock.
  • There is no SysReq key yet.

On an 84-key keyboard:

  • The PrtScr function is still Shift and PrtScr *.
  • The Break function is still Ctrl and Scroll Lock.
  • SysReq was added on a dedicated key.

On a Model M keyboard:

  • Print Screen is now the unmodified label of a key. But presumably, a Shift and Print Screen keypress was still needed in some software that was designed for older keyboards or scan codes.
  • Break is now Ctrl and Pause. The "Ctrl" labels on the Ctrl keys and the "Break" label on the front of the Pause key are both black, to help indicate you should press Ctrl and Pause to get the Break function.
  • SysReq is now Alt and Print Screen. The "Alt" labels on the Alt keys and the "SysReq" label on the front of the Print Screen key are both green, to help indicate you should press Alt and Print Screen to get the SysReq function. Presumably, the Ctrl and Print Screen keystroke was still used in some places to start and end echoing lines to the printer, so they decided to move the SysReq to Alt and Print Screen and the labels were originally color coded green to indicate the different Alt usage. Later keyboards simplified by having the labels on all the keys use the same color, then by moving the labels from the front of the keys to the top of the keys and using a line to divide the unmodified and modified labels, then by dropping the line.
1
  • I'm quite confident that in "compatibility mode" (that is scan code set 1 and 2), an AT keyboards sends the "E0 Shift KeyPad*" sequence for PrtSc, as long as Shift is not actually pressed. An XT keyboard driver will ignore the unknown prefix of "E0". An AT keyboard driver will know that the "Shift" press is fake and this is in fact a PrtSc key press. On the other hand, the Keypad* key will send "E0 Release-Shift KeyPad*" in case you enter Shift-Star, so an XT keyboard driver will see a star instead of PrtSc. IBM went great lengths on having 101/102 keyboards being compatible. Commented May 26 at 12:22
9

It depends on which era keyboard you have. Not all keyboards have the same buttons and they don't work identically.

And every time there was some changes and key functions were combined or shuffled around, the newer keyboard may need to emulate older keyboard, and thus sending a completely different scan code based on if some key was pushed with some modifier.

For example on original PC keyboard the Print Screen was invoked with Shift-* so a newer keyboard with Print Screen button sends a sequence of Extended-LeftShift-Extended-. The user just needs to push thr Print Screen button, but BIOS will just see same combination as before, Shift-.

For example, the 1984 Model F AT keyboard has separate SysRq button, but the 1986 Model M AT keyboard has a shared PrintScreen/SysRq button.

From the AT keyboard onwards to the most modern keyboards for PS/2 compatible PCs, the Print Screen button prints the screen. It does not need any modifiers. It sends a key code of print screen button. If you press the same key with AltGr modifier, the same button sends a key code of SysRq button.

Same with the Break and Pause buttons. The former keyboard had no pause button, but it had shared ScrollLock/Break button.

So AT keyboard sends a bit different scan codes to motherboard keyboard controller, and it did some translation before BIOS gets the XT compatible scancode or extended scancode, and the BIOS gives these to DOS or other programs that read through BIOS, or things like games would read the scancodes or extended scancodes from keyboard controller if they installed a custom interrupt handler.

So depending on keyboard, anything might be correct.

Break key was shared with different keys but Break was always invoked with Ctrl modifier. In extended scan code set, Scroll Lock is 46h but Ctrl-Pause key is Break which is extended E0h 46h scancode so same scancode if extension is ignored.

And how it really works is that when BIOS gets scan codes from keyboard controller, it keeps track of the modifier keys and reacts to some special combinations. If BIOS sees scancode of Print Screen button, it executes software interrupt vector 5h. If BIOS sees scancode of Break, it executes software interrupt vector 1Bh.

If DOS or any program hooks to these interrupt vectors, it knows a special key has been pushed, the Break for example most often is used to stop executing the current program or operation, and mostly interrupt 5h was left to be handled by BIOS which printed the screen to printer on parallel port.

5
  • "On the most modern keyboards, Print Screen button prints the screen. It does not need any modifiers." has been true for quite a while (10+ years IIRC). And of course for a couepl of decades before that, at least, it "printed" the screen to the clipboard on a lot of windowed systems. But there are useful modifiers (Alt+PrntScrn to print the active window, Shift+PrntScrn to define an area to capture - at least on my Linux systems)
    – Chris H
    Commented May 24 at 15:51
  • @ChrisH I don't deny that but this is not about windowed systems with clipboard or Linux. These OSes can do whatever they like without BIOS.
    – Justme
    Commented May 24 at 15:56
  • Of course modern keyboards can be used on non-windowed systems. But I expect all "the most modern" are USB or BlueTooth; BIOS support for features of the the former is still variable, though basic operation has been supported for a long time (not forever - I have owned systems with USB ports but no BIOS support for USB keyboards), no idea about the latter.
    – Chris H
    Commented May 24 at 17:03
  • @ChrisH This is for XT, AT and PS/2 era keyboards. By modern I meant for the era, not current USB keyboards, but they somewhat base on PS/2 keyboards for layout - scancodes being completely different. If motherboard supports, USB keyboards happily work through BIOS and you can use them in DOS.
    – Justme
    Commented May 24 at 17:47
  • 1
    That use of "modern" wasn't at all obvious. In this context it's often used in contrast to "retro". I think a word or 2 from your previous comment would enhance the answer, at which point my comments would clearly not fit and could be tidied up. "The most modern" is particularly misleading, combined with the present tense. It's hard to parse as anything other than the current state of the art, even knowing what you meant.
    – Chris H
    Commented May 25 at 8:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .