Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get numeric keypad arrows working with java applications on Linux

The arrow keys on the numeric keypad do not work with Java applications on Linux. Strangely enough, the Home, End, PgUp, PgDn, Ins, Del all work.

This is especially annoying when using Intellij for programming.

How do you get the arrow keys working?

like image 985
Peter L Avatar asked Sep 24 '15 04:09

Peter L


People also ask

Are the dedicated arrow keys and numeric keypad arrow keys the same?

When I use the "Find Actions by shortcut" box, the dedicated arrow keys and the numeric keypad arrow keys (num lock off) produce the same code. The both say Up, Down, Left or Right so I can't distinguish between those two sets of keys. They should produce the same result but when I'm in the editor, they don't.

Can I use the arrow keys on the keyboard?

The arrow keys in the main part of the keyboard are small and inconvenient to use. I would like to use the arrows keys that are part of the numeric key pad. The keys on the numeric keypad normally produce numbers of course but if I hit num lock so num lock is off they become arrow keys.

Does the Num Lock function do anything for standard arrow keys?

While the num lock function does not do anything for the standard arrow keys, it could be the reason behind your keypad arrow keys not functioning as needed.

How can I emulate the numeric keypad keys in Windows?

I want to emulate the way the numeric keypad keys behave in Windows, i.e. basically NOT to type numbers, but to navigate the caret ("keyboard cursor") on screen, including, crucially, the ability to go shift+numeric_number = "extend selection". Your experience will differ no doubt if your OS is different and you want to achieve something different.


2 Answers

IntelliJ (and CLion) provides the functionality to configure key mappings. Under File->Settings->Keymap->Editor actions it is possible to assign both of the keystrokes ("normal" up/down/left/right and the keypad ones) to corresponding actions. Once this is done, all works like a charm. No need to fiddle with xkb or something.

like image 52
0x416e746f6e Avatar answered Nov 15 '22 19:11

0x416e746f6e


Physical keys on a keyboard are mapped to key codes using xkb. Here's how I got numeric keys working with java applications (like Intellij) on a Debian derivative of Linux:

  1. Switch to root user
  2. cd /usr/share/X11/xkb/symbols
  3. cp keypad keypad.original (just in case)
  4. Edit keypad and replace all occurrences of KP_Up, KP_Down, KP_Left & KP_Right with Up, Down, Left & Right, respectively
  5. Save
  6. dpkg-reconfigure xkb-data
  7. Reboot

Now the numeric keypad will emit the regular, arrow, key codes and not the java-unrecognised, numeric keypad, arrow, key codes.

like image 21
Peter L Avatar answered Nov 15 '22 19:11

Peter L