Most laptops require pressing Fn to get the SysRq key. Pressing Fn usually doesn't affect the Alt key (at least the left one) but may affect the letter that you press after SysRq. Fortunately, you don't need to press SysRq and the third key together, it's enough to hold Alt down. The following sequence works on all the laptops I've seen:
- Press and hold Alt.
- Press Fn, press the SysRq key, and release both.
- Briefly the letter or punctuation key, e.g. S to sync.
- Release Alt.
The SysRq key is usually the same key as PrintScreen. If your keyboard doesn't have a key labeled SysRq or PrintScreen, it may not have a key that sends the scan code that Linux expects. For the purpose of magic SysRq, the SysRq key is whichever key sends the scan code 99.
With a PS/2 keyboard (including a laptop's internal keyboard), to find out what scan code a key sends, log into a text console (press Ctrl+Alt+F1 to switch to a text console, and usually Ctrl+Alt+F7 to go back to the GUI), and run the command
showkey -s displays the scan code of each key as you type it. That's usually one byte (two hexadecimal digits) for a key press, then another byte for the key release. For a few keys, you'll get a byte sequence consisting of two bytes starting with
e0. Press the key you're interested in, then wait 10 seconds and
showkey will exit.
Now that you've identified a scan code, run
setkeycodes … 99 as root to assign that scan code to key code 99. For example, if
showkey -s prints
0xe0 0x6f 0xe0 0xef for the key you've chosen, run
setkeycodes e06f 99.
To make this change permanent, either add the
setkeycodes command to
/etc/rc.local, or configure udev to change the keycode mappings. Configuring udev is the only solution for a USB keyboard,
setkeycodes doesn't affect USB keyboards.