Stop reading if uname -r
returns a Linux version greater than 5.9, since scrollback has been simply removed (1, 2).
My keyboard does not have separate PgUp and PgDown keys. They are in the numpad, sharing their position with KP_9 and KP_3.
Scrolling terminals with Shift+Pg{Up,Down}
was not possible either with
Numlock on or off.
Since I don't care for the keypad numbers but do care a lot for scrolling,
I have successfully remapped them in X11 to "Prior" and "Next" regardless
of Numlock state, and now Shift+{PgUp,Down}
both work in Xterm.
However, I can't achieve the same in the TTY. With other keyboards that had exclusive Page keys, I could use Shift+PgUp
to scroll back after cat
ing a large file, for example.
Original keycodes
As of showkeys
:
KP_3/KP_PgUp = 73
KP_9/KP_PgDown = 81
Slash = 89
Right Shift = 54
As of dumpkeys
:
PgUp = 104
PgDown = 109
Slash and Right Shift were also listed because I will also swap them just for testing.
Attempts
Modified
/etc/console-setup/remap.inc
to exactly this:keycode 73 = Prior shift keycode 73 = Scroll_Backward shift shiftl keycode 73 = Scroll_Backward shift shiftr keycode 73 = Scroll_Backward shift shiftl shiftr keycode 73 = Scroll_Backward shift ctrll keycode 73 = Scroll_Backward shift shiftl ctrll keycode 73 = Scroll_Backward shift shiftr ctrll keycode 73 = Scroll_Backward shift shiftl shiftr ctrll keycode 73 = Scroll_Backward keycode 81 = Next shift keycode 81 = Scroll_Forward shift shiftl keycode 81 = Scroll_Forward shift shiftr keycode 81 = Scroll_Forward shift shiftl shiftr keycode 81 = Scroll_Forward shift ctrll keycode 81 = Scroll_Forward shift shiftl ctrll keycode 81 = Scroll_Forward shift shiftr ctrll keycode 81 = Scroll_Forward shift shiftl shiftr ctrll keycode 81 = Scroll_Forward keycode 89 = Shift keycode 54 = slash shift keycode 54 = question altgr keycode 54 = degree shift altgr keycode 54 = questiondown
Followed the instructions of How to change console keymap in Linux?.
dumpkeys > pageupdown
Then swapped
keycode 73 keycode 104 keycode 81 keycode 109 keycode 54 keycode 89
in that file and issued
loadkeys -s pageupdown
.
Results
In both experiments,
Although the two keypad keys don't print numbers anymore and
PgUp
still works (it scrolls inless
) as desired,Shift+PgUp
does not scroll the TTY.Right Shift and Slash have been correctly swapped.
Additional notes
Toggling Numlock does not help in any of the configurations. The Fn key also does not have any effect in those keys.
I have also tried mapping more ordinary keys, namely
l
andp
, to the Page actions, without success.If it helps in any way, this is the XKB map that works in the X session:
partial keypad_keys xkb_symbols "noKPNumbers" { key <KP9> { [ Prior, Prior ] }; key <KP3> { [ Next, Next ] }; };
How can I map the keypad PgUp and PgDown keys in such a way that Shift+Pg{Up,Down}
scroll the TTY buffer? Is it possible at all?
/etc/default/keyboard
on Debian-based systems. However, I couldn't get it to work outside of X either... – Jaap Joris Vens Oct 21 '20 at 17:52loadkeys
is responsible for loading the keymap, confirming that my approach is technically correct. – Quasímodo Oct 25 '20 at 10:51tmux
orscreen
after logging in and use their respective scrollback. The advantage being that you don't have to care where and how the shell is launched (tty, serial, xterm, something else), the scrolling works the same every time. You also get copy/paste everywhere which is nice. – Patrick Oct 30 '20 at 12:43