11

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?

Peter L
  • 2,921
  • 1
  • 29
  • 31
  • I used to use this approach with a keyboard that had an 'Fn' key. But now I simulate an 'Fn' key on a conventional keyboard using xkb: http://stackoverflow.com/q/32822857/358006 . But thank you @mikesullivan who appears to have a simpler answer than mine. – Peter L Mar 03 '16 at 04:58

3 Answers3

8

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.

0x416e746f6e
  • 9,872
  • 5
  • 40
  • 68
  • This works like a charm for all keypad keys except the "Del" button, which CLion interprets as "Period" – shoosh Apr 30 '18 at 08:08
7

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.

Peter L
  • 2,921
  • 1
  • 29
  • 31
  • Hi Peter, I'm trying to do the same thing (but I use capslock to access extra keys and keymap slightly differs) and faced the same problems. I'm curious if this trick solves the issue for Freeplane on your installation. For me `RedirectKey` works in non-java apps and some java apps like Eclipse, but fails to work in Freemind/Freeplane. I managed to make Freeplane see these keys using overlays, but failed to make keys with modifiers (like `u` for `Ctrl-Left` and `o` for `Ctrl-Right` with `RedirectKey(modifiers=Control, ...)`) and got strange bugs when pressing capslock with other modifier keys. – krvkir May 28 '16 at 22:47
  • @krvkir, Sorry but I don't use Freeplane. I thought the xkb hack would work for everything. I use a similar xkb hack every day to get [an integrated cursor movement keypad](http://stackoverflow.com/q/32822857/358006) which works for all my purposes. – Peter L May 31 '16 at 02:34
  • It may sound like the [other answer](https://stackoverflow.com/a/35294263/1509695) implies _why_ this change is needed ... – matanster Sep 23 '20 at 20:43
  • @matanster, not sure what you mean. – Peter L Sep 24 '20 at 23:13
2

Another option:

  1. edit /etc/default/keyboard (save a copy just in case)
  2. Add or Update the value for XKBOPTIONS to "numpad:microsoft"
  3. Save File
  4. reboot
MikeSullivan
  • 453
  • 5
  • 10