Linux: Keyboard Tools for Key Layout, Keymapping, Keybinding ⌨

, , …,

This page is a list of Linux keyboard tools and tutorial.

If you are using a popular desktop such as Gnome, KDE, Ubuntu, Xfce, LXDE, your first stop is the Control Panel (aka Settings Manager, Preference Pane). There, usually there's apps named {Window Manager, keyboard}. The Window Manager is for all keys that control windows, such as {next/previous window, close window, max window, hide window, move window, cycle workspace, …}. The Keyboard one lets you set keys to launch apps, or swap modifiers. You can change keys for many default actions there. Also, you can create new keys to run a terminal command.

xfce keyboard setting panel 2013-06-01
xfce keyboard setting panel
xfce window manager keys setup  2013-06-07
xfce window manager keys setup

For more advanced keyboarding, there are 2 steps to set keys in general:

Simple Swapping Keys


xmodmap is a simple tool that lets you remap/swap keys for apps running under X11.

See: Linux: xmodmap Tutorial ⌨

scancode, keycode, keysym

How find the scancode of a key?

First, switch to Virtual Console. 〔☛ Linux: Ctrl+Alt+F1 → Virtual Console, How to Get Out ⌨〕 Then, type showkey --scancodes. Then, type any key, it'll print its scancode in hexadecimal. To exit, just wait for 10 seconds.

See man showkey and showkey --help

How find the the keycode & keysym of a key?

Type xev, then press a key.

See man xev

How to set system keyboard layout?

See: Linux: Set System Keyboard Layout ⌨

Tool to Bind Key


if your desktop doesn't provide a way to bind a key to launch a script, then you can use xbindkeys.

(note: i tried xbindkeys under Ubuntu/xfce. Doesn't work in my first 30 min of looking into it.)

xbindkeys is a program that allows you to launch shell commands with your keyboard or your mouse under X Window. It links commands to keys or mouse buttons, using a configuration file. It's independent of the window manager and can capture all keyboard keys (ex: Power, Wake…).

xbindkeys home page:

xbindkeys can bind almost any key or key combination. Example: Caps Lock, ScrLk, Pause, F2, number pad keys, multimedia keys, and special app launch buttons, and also standard modifier key combinations such as ▤ Menu, 【Ctrl+3】, 【❖ Super+3】, etc.

Install: sudo apt-get install xbindkeys. There's also a GUI wrapper: sudo apt-get install xbindkeys-config

You must first create the config file yourself. Do:

xbindkeys -d > ~/.xbindkeysrc

The xbindkeys -d will print out a default config sample file.

Then, either manually modify the config file, when done, sent it a HUP signal to apply your change, like this killall -HUP xbindkeys.

Or, launch the GUI tool to set keys by xbindkeys-config &.

The hard part is the action part. You need to find write a shell command. Basically, call command that do what you want, ⁖ switch to a specific app, or press some other key such as 【Ctrl+w】 for close tab. The hard part is figuring out the syntax of this action command.

Tool for Key Actions

Command Tool to Switch Windows: wmctrl

wmctrl is a command line util to manipulate windows. ⁖ {switch, close, move, resize, set title, list, …}.

To install: sudo apt-get install wmctrl

Example use:

Use xprop util to find the name of a app's window class name. 〔☛ Linux: Commands Related to GUI Apps〕)

here's some popular app's window class name:

Global Set Copy Paste to F3 F4, Using xvkbd

xvkbd is a virtual keyboard for X window system

Here's how to set {F2, F3, F4} keys to do {cut, copy, paste}, globally.

Install xvkbd sudo apt-get install xvkbd, and also install sudo apt-get install xbindkeys, then, add these lines into ~/.xbindkeysrc:

"xvkbd -no-jump-pointer -xsendevent -text "\Cx" 2>/dev/null"
    m:0x0 + c:68

"xvkbd -no-jump-pointer -xsendevent -text "\Cc" 2>/dev/null"
    m:0x0 + c:69

"xvkbd -no-jump-pointer -xsendevent -text "\Cv" 2>/dev/null"
    m:0x0 + c:70

(thanks to XueFuqiao)

Tool to Type Other Keys: xdotool

xdotool. «programatically simulate keyboard input and mouse activity. It does this using X11's XTEST extension and other Xlib functions.»

(note: i tried xdotool under Ubuntu/xfce. Doesn't work in my first 30 min of looking into it.)

Install: sudo apt-get install xdotool

Example. Send 【Ctrl+w】 to close tab. xdotool key --delay 40 Control_L+w

Example. Click on upper left corner, (90, 10) pixels. xdotool mousemove 90 10 click 1

Tool to Expand Abbreviations: AutoKey

AutoKey. For expanding abbrev to full words/text.

Install: sudo apt-get install autokey-gtk (for Gnome) or sudo apt-get install autokey-qt (for KDE)

Other Keyboard Tools

xkb: X Keyboard Extension

xkb (X Keyboard Extension) is a more capable system to set keys in X11, than xmodmap.

setxkbmap → set the keyboard using the X Keyboard Extension.

xkb tutorial

Mouse Extra Button Tools

How to set 5 buttons mouse?

apt-get install imwheel for config mouse buttons.

Bind Keys in Emacs

See: Emacs Keybinding, Keyboard, Articles Index.

Linux: Control Sound Level with Command Line

# increase sound level
amixer sset Master 8%+

# decrease sound level
amixer sset Master 8%-

# set to specific sound level
amixer sset Master 50%
# show a text gui mixer control panel
alsamixer scontrols


dumpkeys -l

blog comments powered by Disqus