Debian – Scrolling TTY without dedicated PgUp and PgDown

consoledebiankeyboard-layoutscrollingtty

My keyboard does not have separate PgUp and PgDown keys.
They are in the numpad, sharing their position with KP_9 and KP_3.

Keypad picture

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 cating 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 in less) 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 and p, 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?

Best Answer

The reason it doesn't work is that you are trying to add form control to a formless output. There is no Buffer to scroll.

That may not seem to make sense, so let me explain. TTY is a historical artifact from when Console output was to an actual TTY or TeleTYpe device. It was a serial terminal printer, search up a LA120 from DEC for an example. You can actually still do this hooking a line printer into /dev/tty. Some server hardware also will allow you to redirect this output at the BIOS level to a serial device. It comes in darn handy if you know how to use it in the absolute worst case hardware troubleshooting scenarios.

The TTY printer would print every line just as it happened and then the paper piled up on the floor of the Operations room. What is on the screen is just what was printed within the screen buffer. there is no other retained information to scroll though.

The Console TTY is meant as a last ditch effort to retain some sort of log even when everything else shits the bed. Its where the disk full message or the seg fault that halts the system shows up to give the actual operator some clue why the system is using electricity but not being otherwise useful.

Related Question