9

As you know directional key and page keys are used to move between command history items. How can I scroll up using the keyboard?

Real Dreams
  • 5,408

2 Answers2

8

cmd.exe is a shell and not a terminal. Many terminals actually have their own way to scroll the console window without passing the shortcut key to the shell so you can easily scroll any shells running in it including cmd

The default terminal in older Windows is conhost.exe and it's scrolling feature can be accessed via Alt+Space, E, L then Up/Down or PageUp/PageDown as Remirol answered (update: now deleted), and it works in PowerShell too because PowerShell also uses conhost by default. But PowerShell already has its own more convenient scrolling shortcut which is PageUp/PageDown. Other shells may have similar keys, like Shift+PageUp/PageDown in bash. Unfortunately cmd only has a key to scroll by line and not by page

If you use another better terminal then they likely have their own scrolling shortcut. For example

  • In Windows terminal (default in Windows 11 and can be installed to older Windows) shortcut keys can be defined by yourself in settings.json. Here's an example that you can add to the "keybindings" array in that file

      // Unbind keys first from any other actions so that we can use
      { "command": "unbound", "keys": "ctrl+shift+pageup" },
      { "command": "unbound", "keys": "ctrl+shift+pagedown" },
      { "command": "unbound", "keys": "ctrl+shift+up" },
      { "command": "unbound", "keys": "ctrl+shift+down" },
    

    { "command": "scrollUpPage", "keys": "ctrl+shift+pageup" }, { "command": "scrollDownPage", "keys": "ctrl+shift+pagedown" }, { "command": "scrollUp", "keys": "ctrl+shift+up" }, { "command": "scrollDown", "keys": "ctrl+shift+down" },

  • In ConEmu (and its "extension" cmder) there are various Key.Buf*Up and Key.Buf*Dn events to scroll the buffer. By default Ctrl+Up/Down and Ctrl+PgUp/PgDn will be used to scroll a line and a page respectively

phuclv
  • 30,396
  • 15
  • 136
  • 260
0

The answer by user "phuclv" got me there 95% of the way. The only difference on Windows 11 cmd Version 10.0.22631.4317 was the section of the commands. Instead of "keybindings", they go under "actions".

I also customized the keys to align with PuTTY default actions.

Example:

    "actions":
    [
        // Unbind keys first from any other actions so that we can use
        { "command": "unbound", "keys": "shift+pageup" },
        { "command": "unbound", "keys": "shift+pagedown" },
        { "command": "unbound", "keys": "ctrl+pageup" },
        { "command": "unbound", "keys": "ctrl+pagedown" },
    { "command": "scrollUpPage", "keys": "shift+pageup" },
    { "command": "scrollDownPage", "keys": "shift+pagedown" },
    { "command": "scrollUp", "keys": "ctrl+pageup" },
    { "command": "scrollDown", "keys": "ctrl+pagedown" }
],