11

I'm using PuTTY on an old Windows laptop to communicate with Ubuntu.

When using the terminal, everything is fine and I can use the numpad normally. However, when I open anything in nano, all these keys have functions instead of numbers.

I did a search about this and found a few solutions to change PuTTY settings, but they didn’t have any effect. Is this an issue with PuTTY or with nano?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Grey Mahagone
  • 149
  • 1
  • 4
  • as far as iam aware, nano has no preferences on this. this should be purely related to the input the program (nano) gets. try other programs as well plz and say how they react. e.g. vi (its a texteditor as well, but a little harder to use) – jonas_toth Dec 26 '16 at 19:25
  • Re *"use the numpad normally"*: With [Num Lock](https://en.wikipedia.org/wiki/Num_Lock) on, presumably? – Peter Mortensen Sep 09 '22 at 11:23

2 Answers2

36

For anyone else with this problem—this is PuTTY specific and is caused by the application keypad mode sending escape sequences to nano.

To solve it:

From an open PuTTY terminal:

  • Ctrl + right-click to bring up the context menu
  • Select "Change Settings..."
  • Select TerminalFeatures in the left-hand navigation tree
  • Check "Disable application keypad mode"

Reference: Description of bug on the Vim (FANDOM.com??) wiki

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
zrobotics
  • 361
  • 1
  • 4
  • 3
  • Thanks! no clue what I did to make the number pad / keypad STOP working when it was fine, but this fixed it - SUPER thanks. – h pic Jan 24 '22 at 01:39
  • That's disturbing though, I did that and it worked in the shell, but I had to do it again in nano when it was running. How can launching a program be detected by PuTTY? – RedGlyph May 12 '22 at 15:53
  • What ***kind*** of escape sequences? For cursor keys, PgUp, PgDn, Home, etc. (corresponding to Num Lock ***not*** on)? [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code)? – Peter Mortensen Sep 09 '22 at 11:31
  • OMG! You are a lifesaver this was absolutely driving me nuts and it is hard to break the muscle memory of quickly entering in number via numpad. 100% solved the issue and makes sense why numpad worked in everything else. – Dizzixx Jul 26 '23 at 22:41
0

nano uses the curses keypad function, turning it on (so that curses handles cursor-keys). The terminal description turns on application mode for both the cursor-keys and the numeric keypad, which with PuTTY makes it send the non-numeric stuff.

You could modify the terminal description to remove the numeric-keypad part of the smkx capability:

infocmp -1 >foo
vi foo
... look for smkx=\E[?1h\E=,
... change that to smkx=\E[?1h,
tic foo
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105