terminal.app eats SHIFT key when used with UP and DOWN arrows (but not left or right)

Using cat in Terminal.app in order to view the raw codes, I get the following:

$ cat
^[[D    # LEFT
^[[1;2D # S-LEFT
^[[C    # RIGHT 
^[[1;2C # S-RIGHT
^[[A    # UP
^[[A    # S-UP
^[[B    # DOWN
^[[B    # S-DOWN

where:

  • S is for the shift key
  • LEFT is for left arrow
  • RIGHT is for right arrow
  • UP is for up arrow
  • DOWN is for down arrow

Thus, the shift key is ignored in conjunction with the up and down arrows, but not with the left and right arrows.

I don't see anything under Terminal > Preferences > Profiles > keyboard that would explain this behaviour (following this answer, that is how I solved a similar problem).

I could probably use DefaultKeybinding.dict (see this other answer for example) but that doesn't explain the behaviour.


I'm not sure what there is to "explain". If you want them to be recognized, define them in your terminal profile.

The canonical list of ANSI keycodes I usually use is here:

https://github.com/timothybasanov/terminal-app-function-keys

 ⇧↑ \033[1;2A
 ⇧↓ \033[1;2B