Difference between revisions of "Keyboard shortcuts"

From ArchWiki
Jump to: navigation, search
m (Key binding for X-selection-paste: wording/accuracy)
 
(157 intermediate revisions by 38 users not shown)
Line 1: Line 1:
[[Category:Other desktop user's resources (English)]]
+
[[Category:Keyboard configuration]]
{{i18n_links_start}}
+
[[Category:X server]]
{{i18n_entry|English|List of Keyboard Shortcuts}}
+
[[Category:Accessibility]]
{{i18n_entry|简体中文|键盘快捷键列表}}
+
[[ja:キーボードショートカット]]
{{i18n_links_end}}
+
[[ru:Keyboard shortcuts]]
 +
[[zh-hans:Keyboard shortcuts]]
 +
This article provides a list of (not commonly known) default keyboard shortcuts and provides information about user customization.
  
==Kernel==
+
== Standard shortcuts ==
These are low level shortcuts that are considered to be used for debugging. Whenever possible, it is recommended to use these instead of doing a hard shutdown (holding power button to shutdown the motherboard).
 
  
Must be activated first with <code>echo "1" > /proc/sys/kernel/sysrq</code> or if you wish to have it enabled during boot, edit /etc/sysctl.conf and set kernel.sysrq = 1
+
=== Kernel ===
  
 +
There are several low level shortcuts that are implemented in the kernel which can be used for debugging and recovering from an unresponsive system. Whenever possible, it is recommended that you use these shortcuts instead of doing a hard shutdown (holding down the power button to completely power off the system).
  
A common idiom to remember this is "'''R'''eboot '''E'''ven '''I'''f '''S'''ystem '''U'''tterly '''B'''roken" (also referred to as "REISUB").  
+
To use these, they must first be activated with either {{ic|1=sysctl kernel.sysrq=1}} or {{ic|echo "1" > /proc/sys/kernel/sysrq}}. If you wish to have it enabled during boot, add {{ic|1=kernel.sysrq = 1}} to your [[sysctl#Configuration|sysctl configuration]].  If you want to make sure it will be enabled even before the partitions are mounted and in the initrd, then add {{ic|1=sysrq_always_enabled=1}} to your [[kernel parameters]].
  
 +
A common idiom to remember this is "'''R'''eboot '''E'''ven '''I'''f '''S'''ystem '''U'''tterly '''B'''roken" (also referred to as "REISUB"). Alternatively, think of it as "BUSIER"  backwards.
  
{|
+
{| class="wikitable"
 +
! Keyboard Shortcut
 +
! Description
 +
|-
 +
| {{ic|Alt+SysRq+r}} Unraw
 +
| Take control of keyboard back from X.
 
|-
 
|-
| {{keypress|Alt}}+{{keypress|SysRq}}+{{keypress|R}}+
+
| {{ic|Alt+SysRq+e}} Terminate
| '''Unraw''' -- Take control of keyboard back from X.
+
| Send SIGTERM to all processes, allowing them to terminate gracefully.
 
|-
 
|-
 
+
| {{ic|Alt+SysRq+i}} Kill
 +
| Send SIGKILL to all processes, forcing them to terminate immediately.
 
|-
 
|-
| {{keypress|Alt}}+{{keypress|SysRq}}+{{keypress|E}}+
+
| {{ic|Alt+SysRq+s}} Sync
| '''Terminate''' -- Send SIGTERM to all processes, allowing them to terminate gracefully.
+
| Flush data to disk.
 
|-
 
|-
 
+
| {{ic|Alt+SysRq+u}} Unmount
 +
| Unmount and remount all filesystems read-only.
 
|-
 
|-
| {{keypress|Alt}}+{{keypress|SysRq}}+{{keypress|I}}+
+
| {{ic|Alt+SysRq+b}} Reboot
| '''Kill''' -- Send SIGKILL to all processes, forcing them to terminate immediately.
+
| Reboot
 
|-
 
|-
 +
|}
 +
 +
{{Tip|
 +
* If you are using a [[display manager]] and after {{ic|Alt+SysRq+e}} you are presented with the login screen (or full desktop if autologin is enabled), it is most likely caused by {{ic|1=Restart=always}} directive in the relevant [[systemd|service file]]. If necessary, [[systemd#Editing provided units|edit the unit]], however this should not prevent the "REISUB" sequence from working.
 +
* If all the above combinations work except {{ic|Alt+SysRq+b}}, try using the contralateral {{ic|Alt}} key.
 +
* On laptops that use {{ic|Fn}} key to differentiate {{ic|SysRq}} from {{ic|PrtScrn}}, it may not actually be necessary to use the {{ic|Fn}} key (i.e., {{ic|Alt+PrtSc+''letter''}} could work).
 +
* On Lenovo laptops {{ic|SysRq}} is often configured as {{ic|Fn+S}}. To use it press and hold {{ic|Alt}} then press {{ic|Fn+s}}, '''release''' {{ic|Fn}} and {{ic|s}} still holding {{ic|Alt}} followed by the keys above.
 +
* You may need to press {{ic|Ctrl}} along with {{ic|Alt}}. So for example, full key shortcut would be {{ic|Ctrl+Alt+SysRq+b}}.
 +
}}
  
|-
+
See [[Wikipedia:Magic SysRq key]] for more details.
| {{keypress|Alt}}+{{keypress|SysRq}}+{{keypress|S}}+
 
| '''Sync''' -- Flush data to disk.
 
|-
 
  
|-
+
=== Terminal ===
| {{keypress|Alt}}+{{keypress|SysRq}}+{{keypress|U}}+
 
| '''Unmount''' -- Unmount and remount all filesystems read-only.
 
|-
 
  
|-
+
==== Virtual console ====
| {{keypress|Alt}}+{{keypress|SysRq}}+{{keypress|B}}+
 
| '''Reboot'''.
 
|-
 
|}
 
  
==Terminal==
+
See [[Linux console#Keyboard shortcuts]].
  
===Virtual console===
+
==== Readline ====
{|
 
|-
 
! Keyboard Shortcut
 
! Description
 
|-
 
| {{keypress|Ctrl}}+{{keypress|Alt}}+{{keypress|Del}}
 
| Reboots Computer (specified in /etc/inittab)
 
|-
 
| {{keypress|Alt}}+{{keypress|F1}}, {{keypress|F2}}, {{keypress|F3}}, ...
 
| Switch to <i>n</i>-th virtual console
 
|-
 
| {{keypress|Alt}}+{{keypress|&larr;}}
 
| Switch to previous virtual console
 
|-
 
| {{keypress|Alt}}+{{keypress|&rarr;}}
 
| Switch to next virtual console
 
|-
 
| {{keypress|Scroll Lock}}
 
| When Scroll Lock is activated, input/output is locked
 
|-
 
| {{keypress|&uArr; Shift}}+{{keypress|PgUp}}/{{keypress|PgDown}}
 
| Scrolls console buffer up/down
 
|-
 
| {{keypress|Ctrl}}+{{keypress|C}}
 
| Kills current task
 
|-
 
| {{keypress|Ctrl}}+{{keypress|D}}
 
| Inserts an EOF
 
|-
 
| {{keypress|Ctrl}}+{{keypress|Z}}
 
| Pauses current Task
 
|}
 
  
===Readline===
+
{{Remove|Duplicates [https://tiswww.cwru.edu/php/chet/readline/rluserman.html Info documentation].}}
  
GNU readline is a commonly used library for line-editing,
+
[[Readline]] is a commonly used library for line-editing; it is used for example by Bash, FTP, and many more (see the details of {{Pkg|readline}} package under "Required By" for more examples). Readline is also customizable, see examples on the [[readline]] page.
it is used for example by bash, ftp and many more (see [http://archlinux.org/packages/core/i686/readline/ Arch Package details] under "Required By" for more examples).
 
readline is also customizable (see manpage for details).
 
  
{|
+
{| class="wikitable"
|-
 
 
! Keyboard Shortcut
 
! Keyboard Shortcut
 
! Description
 
! Description
 
|-
 
|-
| {{keypress|Ctrl}}+{{keypress|L}}
+
| {{ic|Ctrl+l}}
 
| Clear the screen
 
| Clear the screen
 
|-  
 
|-  
| colspan=2 align="center" | Cursor Movement
+
| colspan=2 align="center" | '''Cursor Movement'''
 
|-
 
|-
| {{keypress|Ctrl}}+{{keypress|B}}
+
| {{ic|Ctrl+b}}
 
| Move cursor one character to the left
 
| Move cursor one character to the left
 
|-
 
|-
| {{keypress|Ctrl}}+{{keypress|F}}
+
| {{ic|Ctrl+f}}
 
| Move cursor one character to the right
 
| Move cursor one character to the right
 
|-
 
|-
| {{keypress|Alt}}+{{keypress|B}}
+
| {{ic|Alt+b}}
 
| Move cursor one word to the left
 
| Move cursor one word to the left
 
|-
 
|-
| {{keypress|Alt}}+{{keypress|F}}
+
| {{ic|Alt+f}}
 
| Move cursor one word to the right
 
| Move cursor one word to the right
 
|-
 
|-
| {{keypress|Ctrl}}+{{keypress|A}}
+
| {{ic|Ctrl+a}}
 
| Move cursor to start of the line
 
| Move cursor to start of the line
 
|-
 
|-
| {{keypress|Ctrl}}+{{keypress|E}}
+
| {{ic|Ctrl+e}}
 
| Move cursor to end of the line
 
| Move cursor to end of the line
 
|-
 
|-
| colspan=2 align="center" | Copy & Paste
+
| colspan=2 align="center" | '''Copy & Paste'''
 
|-
 
|-
| {{keypress|Ctrl}}+{{keypress|U}}
+
| {{ic|Ctrl+u}}
 
| Cut everything from line start to cursor
 
| Cut everything from line start to cursor
 
|-
 
|-
| {{keypress|Ctrl}}+{{keypress|K}}
+
| {{ic|Ctrl+k}}
 
| Cut everything from the cursor to end of the line
 
| Cut everything from the cursor to end of the line
 
|-
 
|-
| {{keypress|Alt}}+{{keypress|D}}
+
| {{ic|Alt+d}}
 
| Cut the current word after the cursor
 
| Cut the current word after the cursor
 
|-
 
|-
| {{keypress|Ctrl}}+{{keypress|W}}
+
| {{ic|Ctrl+w}}
 
| Cut the current word before the cursor
 
| Cut the current word before the cursor
 
|-
 
|-
| {{keypress|Ctrl}}+{{keypress|Y}}
+
| {{ic|Ctrl+y}}
 
| Paste the previous cut text
 
| Paste the previous cut text
 
|-
 
|-
| {{keypress|Alt}}+{{keypress|Y}}
+
| {{ic|Alt+y}}
 
| Paste the second latest cut text
 
| Paste the second latest cut text
 
|-
 
|-
| {{keypress|Alt}}+{{keypress|Ctrl}}+{{keypress|Y}}
+
| {{ic|Alt+Ctrl+y}}
 
| Paste the first argument of the previous command
 
| Paste the first argument of the previous command
 
|-
 
|-
| {{keypress|Alt}}+{{keypress|.}}or{{keypress|_}}
+
| {{ic|Alt+.}}/{{ic|_}}
 
| Paste the last argument of the previous command
 
| Paste the last argument of the previous command
 
|-
 
|-
| colspan=2 align="center" | History
+
| colspan=2 align="center" | '''History'''
 
|-
 
|-
| {{keypress|Ctrl}}+{{keypress|P}}
+
| {{ic|Ctrl+p}}
 
| Move to the previous line
 
| Move to the previous line
 
|-
 
|-
| {{keypress|Altl}}+{{keypress|N}}
+
| {{ic|Ctrl+n}}
 
| Move to the next line
 
| Move to the next line
 
|-
 
|-
| {{keypress|Ctrl}}+{{keypress|S}}
+
| {{ic|Ctrl+s}}
 
| Search
 
| Search
 
|-
 
|-
| {{keypress|Ctrl}}+{{keypress|R}}
+
| {{ic|Ctrl+r}}
 
| Reverse search
 
| Reverse search
 
|-
 
|-
| {{keypress|Ctrl}}+{{keypress|J}}
+
| {{ic|Ctrl+j}}
 
| End search
 
| End search
 
|-
 
|-
| {{keypress|Ctrl}}+{{keypress|G}}
+
| {{ic|Ctrl+g}}
 
| Abort search (restores original line)
 
| Abort search (restores original line)
 
|-
 
|-
| {{keypress|Alt}}+{{keypress|R}}
+
| {{ic|Alt+r}}
 
| Restores all changes made to line
 
| Restores all changes made to line
 
|-
 
|-
| colspan=2 align="center" | Completion
+
| colspan=2 align="center" | '''Completion'''
 
|-
 
|-
| {{keypress|Tab}}
+
| {{ic|Tab}}
 
| Auto-complete a name
 
| Auto-complete a name
 
|-
 
|-
| {{keypress|Altl}}+{{keypress|?}}
+
| {{ic|Alt+?}}
 
| List all possible completions
 
| List all possible completions
 
|-
 
|-
| {{keypress|Alt}}+{{keypress|*}}
+
| {{ic|Alt+*}}
 
| Insert all possible completions
 
| Insert all possible completions
 
|-
 
|-
 
|}
 
|}
  
==X11==
+
=== Xorg and Wayland ===
  
{|
+
{| class="wikitable"
|-
 
 
! Keyboard Shortcut
 
! Keyboard Shortcut
 
! Description
 
! Description
 +
! Notes
 
|-
 
|-
| {{keypress|Ctrl}}+{{keypress|Alt}}+{{keypress|F1}}, {{keypress|F2}}, {{keypress|F3}}, ...
+
| {{ic|Ctrl+Alt+F1}}, {{ic|F2}}, {{ic|F3}}, ...
| Switch to <i>n</i>-th virtual console
+
| Switch to ''n''-th virtual console
|-
+
| If it does not work, try {{ic|Ctrl+Fn+Alt+F…}}.
| {{keypress|Ctrl}}+{{keypress|Alt}}+{{keypress|+}}/{{keypress|-}}
 
| Switch to higher/lower available resolutions
 
|-
 
| {{keypress|Ctrl}}+{{keypress|Alt}}+{{keypress|Backspace}}
 
| Kills X-server (This may not work for recent updates.)
 
 
|-
 
|-
| {{keypress|Ctrl}}+{{keypress|&uArr; Shift}}+{{keypress|Num Lock}}
+
| {{ic|Shift+Insert}} <br> {{ic|Mouse Button 2}}
| Toggles keyboard mouse; uses numpad, mouse click is done by {{keypress|5}}, use {{keypress|/}}, {{keypress|*}}, and {{keypress|-}}to switch the click to left, middle, and right click
+
| Paste text from the [[Clipboard|PRIMARY buffer]]
 +
| By default, Qt maps {{ic|Shift+Insert}} to CLIPBOARD instead of the PRIMARY buffer (see e.g. [http://doc.qt.io/qt-5/qlineedit.html#details]) and {{ic|Ctrl+Shift+Insert}} is mapped to the PRIMARY buffer.
 
|-
 
|-
| {{keypress|Shift}}+{{keypress|Insert}}, Mouse Button 3
 
| Copy selected text to clipboard, or paste from clipboard
 
 
|}
 
|}
  
==Links==
+
== Customization ==
*[http://lnag.sourceforge.net/lnag_html/node5.html Linux Newbie Administrator Guide - Shortcuts and Commands]
+
 
*[http://tldp.org/HOWTO/Keyboard-and-Console-HOWTO.html The Linux keyboard and console HOWTO]
+
=== Readline ===
 +
 
 +
[[Readline]] has [[Emacs]]-like and [[vi]]-like editing modes which can be customized with escape sequences.
 +
 
 +
=== Xorg ===
 +
 
 +
See [[Xorg/Keyboard configuration#Frequently used XKB options]] for some common shortcuts, that are disabled by default.
 +
 
 +
When we are in a graphical environment we may want to execute a command when certain key combination is pressed (i.e. bind a command to a ''keysym''). There are multiple ways to do that:
 +
 
 +
* The most portable way using low level tools, such as [[acpid]]. Not all keys are supported, but configuration in uniform way is possible for keyboard keys, power adapter connection and even headphone jack (un)plugging events. It is also difficult to run programs inside X session correctly.
 +
* The universal way using [[Xorg]] utilities (e.g. [[xbindkeys]]) and eventually your desktop environment or window manager tools.
 +
* The quicker way using a third-party program to do everything in GUI, such as the Gnome Control Center.
 +
 
 +
==== sxhkd ====
 +
 
 +
A simple X hotkey daemon with a powerful and compact configuration syntax. See [[sxhkd]] for details.
 +
 
 +
==== actkbd ====
 +
 
 +
From [http://users.softlab.ece.ntua.gr/~thkala/projects/actkbd/ actkbd home page]:
 +
:{{AUR|actkbd}} (available in [[AUR]]) is a simple daemon that binds actions to keyboard events. It recognises key combinations and can handle press, repeat and release events. Currently it only supports the linux-2.6 evdev interface. It uses a plain-text configuration file which contains all the bindings.
 +
 
 +
A sample configuration and guide is available [http://users.softlab.ece.ntua.gr/~thkala/projects/actkbd/latest/README here].
 +
 
 +
==== xbindkeys ====
 +
 
 +
[[xbindkeys]] allows advanced mapping of keysyms to actions independently of the Desktop Environment.
 +
{{Tip| If you find {{ic|xbindkeys}} difficult to use, try the graphical manager {{AUR|xbindkeys_config-gtk2}} from the [[AUR]].}}
 +
 
 +
=== Key binding for X-selection-paste ===
 +
 
 +
{{Accuracy|1={{ic|Shift+Insert}} pastes the PRIMARY buffer.}}
 +
{{Expansion|Why the 100ms delay?}}
 +
 
 +
Users who prefer to work with the keyboard rather than the mouse may benefit from a key binding to the paste operation of the middle mouse button. This is especially useful in a keyboard-centered environment. A workflow example is:
 +
 
 +
# In Firefox, select a string you want to google for (with the mouse).
 +
# Hit {{ic|Ctrl+k}} to enter the "search engine" field.
 +
# Hit {{ic|F9}} to paste the buffer, instead of moving the mouse pointer to the field and middle-click to paste.
 +
 
 +
{{Note|{{ic|Shift+Insert}} has a similar yet different functionality, see [[#Xorg]]: {{ic|Shift+Insert}} inserts the clipboard buffer, not the x-selection-paste buffer. In some applications, these two buffers are mirrored.}}
 +
 
 +
The method suggested here uses the following three packages::
 +
 
 +
* {{Pkg|xsel}} to give access to the x-selection-buffer content.
 +
* [[Xbindkeys]] to bind a key-stroke to an action.
 +
* {{AUR|xvkbd}} to pass the buffer string to the application by emulating keyboard input.
 +
 
 +
This example binds the x-selection-paste operation to the {{ic|F9}} key:
 +
 
 +
{{hc|.xbindkeysrc|
 +
"xvkbd -no-jump-pointer -xsendevent -text "\D1`xsel`" 2>/dev/null"
 +
    F9
 +
}}
 +
 
 +
The {{ic|"\D1"}} code prefixes a 100 ms pause to inserting the selection buffer (see the [http://t-sato.in.coocan.jp/xvkbd/ xvkbd home page]).
 +
 
 +
{{Note|Depending on your X configuration, you may need to drop the {{ic|-xsendevent}} argument to xvkbd.}}
 +
The key codes for keys other than {{ic|F9}} can be determined using {{ic|xbindkeys -k}}.
 +
 
 +
References:
 +
 
 +
* [http://unix.stackexchange.com/questions/11889/pasting-x-selection-not-clipboard-contents-with-keyboard Pasting X selection (not clipboard) contents with keyboard]
 +
* [http://homepage3.nifty.com/tsato/xvkbd/ xvkbd home page]
 +
 
 +
==== XMonad Window Manager ====
 +
 
 +
In the {{Pkg|xmonad}} window manager there is a built-in function to paste the x-selection-buffer content.  In order to bind that function to a key-stroke (here {{ic|Insert}} key) the following configuration can be used:
 +
{{hc|xmonad.hs|
 +
import XMonad.Util.Paste
 +
...
 +
  -- X-selection-paste buffer
 +
  , ((0,                    xK_Insert), pasteSelection) ]
 +
}}
 +
 
 +
== Tips and tricks ==
 +
 
 +
* If you like a keyboard-centered workflow, you might also appreciate a [[Window manager#Tiling_window_managers|tiling window manager]].
 +
 
 +
== See also ==
 +
* [https://www.kernel.org/doc/Documentation/sysrq.txt The Linux Magic System Request Key - Kernel documentation]
 +
* [http://lnag.sourceforge.net/lnag_html/node5.html Linux Newbie Administrator Guide - Shortcuts and Commands]
 +
* [http://tldp.org/HOWTO/Keyboard-and-Console-HOWTO.html The Linux keyboard and console HOWTO]

Latest revision as of 05:53, 23 October 2018

This article provides a list of (not commonly known) default keyboard shortcuts and provides information about user customization.

Standard shortcuts

Kernel

There are several low level shortcuts that are implemented in the kernel which can be used for debugging and recovering from an unresponsive system. Whenever possible, it is recommended that you use these shortcuts instead of doing a hard shutdown (holding down the power button to completely power off the system).

To use these, they must first be activated with either sysctl kernel.sysrq=1 or echo "1" > /proc/sys/kernel/sysrq. If you wish to have it enabled during boot, add kernel.sysrq = 1 to your sysctl configuration. If you want to make sure it will be enabled even before the partitions are mounted and in the initrd, then add sysrq_always_enabled=1 to your kernel parameters.

A common idiom to remember this is "Reboot Even If System Utterly Broken" (also referred to as "REISUB"). Alternatively, think of it as "BUSIER" backwards.

Keyboard Shortcut Description
Alt+SysRq+r Unraw Take control of keyboard back from X.
Alt+SysRq+e Terminate Send SIGTERM to all processes, allowing them to terminate gracefully.
Alt+SysRq+i Kill Send SIGKILL to all processes, forcing them to terminate immediately.
Alt+SysRq+s Sync Flush data to disk.
Alt+SysRq+u Unmount Unmount and remount all filesystems read-only.
Alt+SysRq+b Reboot Reboot
Tip:
  • If you are using a display manager and after Alt+SysRq+e you are presented with the login screen (or full desktop if autologin is enabled), it is most likely caused by Restart=always directive in the relevant service file. If necessary, edit the unit, however this should not prevent the "REISUB" sequence from working.
  • If all the above combinations work except Alt+SysRq+b, try using the contralateral Alt key.
  • On laptops that use Fn key to differentiate SysRq from PrtScrn, it may not actually be necessary to use the Fn key (i.e., Alt+PrtSc+letter could work).
  • On Lenovo laptops SysRq is often configured as Fn+S. To use it press and hold Alt then press Fn+s, release Fn and s still holding Alt followed by the keys above.
  • You may need to press Ctrl along with Alt. So for example, full key shortcut would be Ctrl+Alt+SysRq+b.

See Wikipedia:Magic SysRq key for more details.

Terminal

Virtual console

See Linux console#Keyboard shortcuts.

Readline

Tango-edit-cut.pngThis section is being considered for removal.Tango-edit-cut.png

Reason: Duplicates Info documentation. (Discuss in Talk:Keyboard shortcuts#)

Readline is a commonly used library for line-editing; it is used for example by Bash, FTP, and many more (see the details of readline package under "Required By" for more examples). Readline is also customizable, see examples on the readline page.

Keyboard Shortcut Description
Ctrl+l Clear the screen
Cursor Movement
Ctrl+b Move cursor one character to the left
Ctrl+f Move cursor one character to the right
Alt+b Move cursor one word to the left
Alt+f Move cursor one word to the right
Ctrl+a Move cursor to start of the line
Ctrl+e Move cursor to end of the line
Copy & Paste
Ctrl+u Cut everything from line start to cursor
Ctrl+k Cut everything from the cursor to end of the line
Alt+d Cut the current word after the cursor
Ctrl+w Cut the current word before the cursor
Ctrl+y Paste the previous cut text
Alt+y Paste the second latest cut text
Alt+Ctrl+y Paste the first argument of the previous command
Alt+./_ Paste the last argument of the previous command
History
Ctrl+p Move to the previous line
Ctrl+n Move to the next line
Ctrl+s Search
Ctrl+r Reverse search
Ctrl+j End search
Ctrl+g Abort search (restores original line)
Alt+r Restores all changes made to line
Completion
Tab Auto-complete a name
Alt+? List all possible completions
Alt+* Insert all possible completions

Xorg and Wayland

Keyboard Shortcut Description Notes
Ctrl+Alt+F1, F2, F3, ... Switch to n-th virtual console If it does not work, try Ctrl+Fn+Alt+F….
Shift+Insert
Mouse Button 2
Paste text from the PRIMARY buffer By default, Qt maps Shift+Insert to CLIPBOARD instead of the PRIMARY buffer (see e.g. [1]) and Ctrl+Shift+Insert is mapped to the PRIMARY buffer.

Customization

Readline

Readline has Emacs-like and vi-like editing modes which can be customized with escape sequences.

Xorg

See Xorg/Keyboard configuration#Frequently used XKB options for some common shortcuts, that are disabled by default.

When we are in a graphical environment we may want to execute a command when certain key combination is pressed (i.e. bind a command to a keysym). There are multiple ways to do that:

  • The most portable way using low level tools, such as acpid. Not all keys are supported, but configuration in uniform way is possible for keyboard keys, power adapter connection and even headphone jack (un)plugging events. It is also difficult to run programs inside X session correctly.
  • The universal way using Xorg utilities (e.g. xbindkeys) and eventually your desktop environment or window manager tools.
  • The quicker way using a third-party program to do everything in GUI, such as the Gnome Control Center.

sxhkd

A simple X hotkey daemon with a powerful and compact configuration syntax. See sxhkd for details.

actkbd

From actkbd home page:

actkbdAUR (available in AUR) is a simple daemon that binds actions to keyboard events. It recognises key combinations and can handle press, repeat and release events. Currently it only supports the linux-2.6 evdev interface. It uses a plain-text configuration file which contains all the bindings.

A sample configuration and guide is available here.

xbindkeys

xbindkeys allows advanced mapping of keysyms to actions independently of the Desktop Environment.

Tip: If you find xbindkeys difficult to use, try the graphical manager xbindkeys_config-gtk2AUR from the AUR.

Key binding for X-selection-paste

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: Shift+Insert pastes the PRIMARY buffer. (Discuss in Talk:Keyboard shortcuts#)

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: Why the 100ms delay? (Discuss in Talk:Keyboard shortcuts#)

Users who prefer to work with the keyboard rather than the mouse may benefit from a key binding to the paste operation of the middle mouse button. This is especially useful in a keyboard-centered environment. A workflow example is:

  1. In Firefox, select a string you want to google for (with the mouse).
  2. Hit Ctrl+k to enter the "search engine" field.
  3. Hit F9 to paste the buffer, instead of moving the mouse pointer to the field and middle-click to paste.
Note: Shift+Insert has a similar yet different functionality, see #Xorg: Shift+Insert inserts the clipboard buffer, not the x-selection-paste buffer. In some applications, these two buffers are mirrored.

The method suggested here uses the following three packages::

  • xsel to give access to the x-selection-buffer content.
  • Xbindkeys to bind a key-stroke to an action.
  • xvkbdAUR to pass the buffer string to the application by emulating keyboard input.

This example binds the x-selection-paste operation to the F9 key:

.xbindkeysrc
"xvkbd -no-jump-pointer -xsendevent -text "\D1`xsel`" 2>/dev/null"
    F9

The "\D1" code prefixes a 100 ms pause to inserting the selection buffer (see the xvkbd home page).

Note: Depending on your X configuration, you may need to drop the -xsendevent argument to xvkbd.

The key codes for keys other than F9 can be determined using xbindkeys -k.

References:

XMonad Window Manager

In the xmonad window manager there is a built-in function to paste the x-selection-buffer content. In order to bind that function to a key-stroke (here Insert key) the following configuration can be used:

xmonad.hs
import XMonad.Util.Paste
...
  -- X-selection-paste buffer
  , ((0,                     xK_Insert), pasteSelection) ]

Tips and tricks

See also