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

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

This is especially annoying when using Intellij for programming.

How do you get the arrow keys?

+6
source share
4 answers

The physical keys on the keyboard are mapped to key codes using xkb . Here's how I got the number keys working with java applications (like Intellij) in a Debian-derived Linux:

  • Switch to root user
  • cd / usr / share / X11 / xkb / symbols
  • cp keyboard keyboard. original (just in case)
  • Edit the keyboard and replace all occurrences of KP_Up, KP_Down, KP_Left and KP_Right using the up, down, left and right buttons, respectively
  • Save
  • dpkg-reconfigure xkb-data li>
  • Reboot

Now the numeric keypad will emit ordinary arrows, key codes, and not a java-unrecognized, numeric keypad, arrows, key codes.

+3
source

IntelliJ (and CLion) provides functionality for customizing key mappings. In the File->Settings->Keymap->Editor actions section, you can assign both keystrokes ("normal" up / down / left / right and on the keyboard) to the corresponding actions. Once this is done, everything works like a charm. No need to mess with xkb or something.

+7
source

I don't have enough reputation for comment, but Peter L's solution really solved this problem for me after a very long struggle.

I created a bash script to automate it, and thought I shared it here:

 #!/bin/bash SYMBOLS="/usr/share/X11/xkb/symbols" KEYPAD="$SYMBOLS/keypad" # create a backup in a temporary directory TMP=$(mktemp -d) cp "$KEYPAD" "$TMP/keypad" # make a numbered backup in the original directory sudo cp --backup=numbered "$TMP/keypad" "$SYMBOLS" # fix the keypad file into the temporary directory KEYS=("Up" "Down" "Left" "Right" "Home" "End" "Prior" "Next") REGEX="s/KP_\("${KEYS[0]}$(printf "\|%s" "${KEYS[@]:1}")"\)/\1/g" sed -e "$REGEX" "$KEYPAD" > "$TMP/keypad" # overwrite the original keypad file sudo cp "$TMP/keypad" "$KEYPAD" # delete the temporary directory rm -rf "$TMP" # update the xkb symbols sudo dpkg-reconfigure xkb-data 

EDIT: Enhanced Version

+2
source

Another option:

  • change / etc / default / keyboard (keep a copy just in case)
  • Add or Update value for XKBOPTIONS on "numpad: microsoft"
  • Save file
  • reboot
+1
source

All Articles