Difference between revisions of "Keyboard shortcuts"

From ArchWiki
Jump to: navigation, search
(X11: not standard shortcut - either dropped or specific to nvidia (oldest reference is http://ubuntuforums.org/showthread.php?t=83973)
(15 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
[[Category:Accessibility]]
 
[[Category:Accessibility]]
 
[[zh-CN:Keyboard Shortcuts]]
 
[[zh-CN:Keyboard Shortcuts]]
{{Article summary start}}
+
This article provides a list of (not commonly known) default keyboard shortcuts and provides information about user customization.
{{Article summary text|Default keyboard shortcuts and user customizations.}}
+
 
{{Article summary end}}
+
== Standard shortcuts ==
==Standard Shortcuts==
+
 
===Kernel===
+
=== Kernel ===
 +
 
 
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).
 
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 {{ic|echo "1" > /proc/sys/kernel/sysrq}} or if you wish to have it enabled during boot, edit {{ic|/etc/sysctl.d/99-sysctl.conf}} and set kernel.sysrq = 1
+
Must be activated first with {{ic|echo "1" > /proc/sys/kernel/sysrq}} or if you wish to have it enabled during boot, edit {{ic|/etc/sysctl.d/99-sysctl.conf}} and set {{ic|1=kernel.sysrq = 1}}
  
 
A common idiom to remember this is "'''R'''eboot '''E'''ven '''I'''f '''S'''ystem '''U'''tterly '''B'''roken" (also referred to as "REISUB").  
 
A common idiom to remember this is "'''R'''eboot '''E'''ven '''I'''f '''S'''ystem '''U'''tterly '''B'''roken" (also referred to as "REISUB").  
  
{|
+
{| style="text-align:left;"
 
! Keyboard Shortcut
 
! Keyboard Shortcut
 
! Description
 
! Description
Line 40: Line 41:
 
See [[wikipedia:Magic SysRq key|Magic SysRq key - Wikipedia]] for more details.
 
See [[wikipedia:Magic SysRq key|Magic SysRq key - Wikipedia]] for more details.
  
===Terminal===
+
=== Terminal ===
  
====Virtual console====
+
==== Virtual console ====
{|
+
 
|-
+
{| style="text-align:left;"
 
! Keyboard Shortcut
 
! Keyboard Shortcut
 
! Description
 
! Description
Line 76: Line 77:
 
|}
 
|}
  
====Readline====
+
==== Readline ====
  
GNU readline is a commonly used library for line-editing,
+
GNU 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 manpage for details).
it is used for example by bash, ftp and many more (see [https://archlinux.org/packages/core/i686/readline/ Arch Package details] under "Required By" for more examples).
+
readline is also customizable (see manpage for details).
+
  
{|
+
{| style="text-align:left;"
|-
+
 
! Keyboard Shortcut
 
! Keyboard Shortcut
 
! Description
 
! Description
Line 172: Line 170:
 
|}
 
|}
  
===X11===
+
=== X11 ===
  
{|
+
{| style="text-align:left;"
|-
+
 
! Keyboard Shortcut
 
! Keyboard Shortcut
 
! Description
 
! Description
Line 181: Line 178:
 
| {{ic|Ctrl}}+{{ic|Alt}}+{{ic|F1}}, {{ic|F2}}, {{ic|F3}}, ...
 
| {{ic|Ctrl}}+{{ic|Alt}}+{{ic|F1}}, {{ic|F2}}, {{ic|F3}}, ...
 
| Switch to <i>n</i>-th virtual console
 
| Switch to <i>n</i>-th virtual console
|-
 
| {{ic|Ctrl}}+{{ic|Alt}}+{{ic|+}}/{{ic|-}}
 
| Switch to higher/lower available resolutions
 
|-
 
| {{ic|Ctrl}}+{{ic|Alt}}+{{ic|Backspace}}
 
| Kills X-server (This may not work for recent updates.)
 
|-
 
| {{ic|Ctrl}}+{{ic|&uArr; Shift}}+{{ic|Num Lock}}
 
| Toggles keyboard mouse; uses numpad, mouse click is done by {{ic|5}}, use {{ic|/}}, {{ic|*}}, and {{ic|-}}to switch the click to left, middle, and right click
 
 
|-
 
|-
 
| {{ic|Shift}}+{{ic|Insert}} <br> {{ic|Mouse Button 3}}
 
| {{ic|Shift}}+{{ic|Insert}} <br> {{ic|Mouse Button 3}}
Line 196: Line 184:
 
|}
 
|}
  
xkeyboard-config disable keyboard mouse by default after the version 2.0.1.To enable it, changing the following line in {{ic|/usr/share/X11/xkb/symbols/pc}}:
+
== User customization ==
{{bc|key <NMLK> { [ Num_Lock ] }; }}
+
back to as it was in version 2.0.1:
+
{{bc|key <NMLK> { [ Num_Lock, Pointer_EnableKeys ] }; }}
+
 
+
===Links===
+
*[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]
+
  
==User Customization==
+
=== Readline ===
===Readline===
+
 
This example adds keys that allow (in ''vi-mode'') to search backward through the history for the string of characters between the start of the current line and the point.  This is a non-incremental search.
 
This example adds keys that allow (in ''vi-mode'') to search backward through the history for the string of characters between the start of the current line and the point.  This is a non-incremental search.
 
{{hc|.inputrc|
 
{{hc|.inputrc|
Line 215: Line 195:
 
}}
 
}}
  
===X11===
+
=== X11 ===
====Modifying the Keyboard Layout====
+
 
This example changes the CapsLock key to only activate caps lock when the Shift key is also pressed
+
See [[Keyboard Configuration in Xorg#Frequently used XKB options]] for some common shortcuts, that are disabled by default.
{{hc|.xinitrc|2=xmodmap -e 'keycode  66 = NoSymbol Caps_Lock Caps_Lock'}}
+
 
The keycode of the CapsLock key can be found in the output of
+
=== Firefox ===
{{ic|xmodmap -pk}}
+
 
 +
Use the [https://addons.mozilla.org/en-us/firefox/addon/customizable-shortcuts/ customizable-shortcuts] add-on.
 +
 
 +
== Tips and tricks ==
 +
 
 +
* If you like a keyboard-centered workflow, you might also appreciate a [[Window_Manager#Tiling_window_managers|tiling window manager]].
 +
 
 +
=== Key binding for X-selection-paste ===
 +
 
 +
{{Accuracy|{{ic|Shift+Insert}} is a standard shortcut with the same effect, see [[#X11]].}}
  
====Key Binding for X-Selection-Paste====
 
 
Users who prefer to work rather with the keyboard 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:
 
Users who prefer to work rather with the keyboard 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).
 
#In Firefox, select a string you want to google for (with the mouse).
Line 229: Line 217:
  
 
The method suggested here uses three packages available in the [[Official Repositories|official repositories]]:
 
The method suggested here uses three packages available in the [[Official Repositories|official repositories]]:
*{{Pkg|xsel}} to give access to the x-selection-buffer content.
+
 
*{{Pkg|xbindkeys}} to bind a key-stroke to an action.
+
* {{Pkg|xsel}} to give access to the x-selection-buffer content.
*{{Pkg|xvkbd}} to pass the buffer string to the application by emulating keyboard input.
+
* {{Pkg|xbindkeys}} to bind a key-stroke to an action.
 +
* {{Pkg|xvkbd}} to pass the buffer string to the application by emulating keyboard input.
  
 
This example binds the x-selection-paste operation to the {{ic|F12}} key:
 
This example binds the x-selection-paste operation to the {{ic|F12}} key:
 +
 
{{hc|.xbindkeysrc|
 
{{hc|.xbindkeysrc|
 
"xvkbd -no-jump-pointer -xsendevent -text "\D1`xsel`" 2>/dev/null"
 
"xvkbd -no-jump-pointer -xsendevent -text "\D1`xsel`" 2>/dev/null"
 
     F12
 
     F12
 
}}
 
}}
 +
 
The {{ic|"\D1"}} code prefixes a 100 ms pause to inserting the selection buffer (see the [http://homepage3.nifty.com/tsato/xvkbd/ xvkbd home page]).
 
The {{ic|"\D1"}} code prefixes a 100 ms pause to inserting the selection buffer (see the [http://homepage3.nifty.com/tsato/xvkbd/ xvkbd home page]).
 +
 
{{Note|Depending on your X configuration, you may need to drop the {{ic|-xsendevent}} argument to xvkbd.}}
 
{{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|F12}} can be determined using {{ic|xbindkeys -k}}.
 
The key codes for keys other than {{ic|F12}} can be determined using {{ic|xbindkeys -k}}.
  
'''See Also:'''
+
'''References:'''
*[http://unix.stackexchange.com/questions/11889/pasting-x-selection-not-clipboard-contents-with-keyboard Pasting X selection (not clipboard) contents with keyboard]
+
* [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]
+
* [http://homepage3.nifty.com/tsato/xvkbd/ xvkbd home page]
  
===Firefox===
+
== See also ==
Use the [https://addons.mozilla.org/en-us/firefox/addon/customizable-shortcuts/ customizable-shortcuts] add-on.
+
  
==Tips==
+
* [http://lnag.sourceforge.net/lnag_html/node5.html Linux Newbie Administrator Guide - Shortcuts and Commands]
*If you like a keyboard-centered workflow, you might also appreciate a [[wikipedia:Tiling_window_manager|tiling window manager]], like [[Xmonad]].
+
* [http://tldp.org/HOWTO/Keyboard-and-Console-HOWTO.html The Linux keyboard and console HOWTO]

Revision as of 22:16, 16 December 2013

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

Standard shortcuts

Kernel

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 echo "1" > /proc/sys/kernel/sysrq or if you wish to have it enabled during boot, edit /etc/sysctl.d/99-sysctl.conf and set kernel.sysrq = 1

A common idiom to remember this is "Reboot Even If System Utterly Broken" (also referred to as "REISUB").

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

See Magic SysRq key - Wikipedia for more details.

Terminal

Virtual console

Keyboard Shortcut Description
Ctrl+Alt+Del Reboots Computer (specified by the symlink /usr/lib/systemd/system/ctrl-alt-del.target)
Alt+F1, F2, F3, ... Switch to n-th virtual console
Alt+ Switch to previous virtual console
Alt+ Switch to next virtual console
Scroll Lock When Scroll Lock is activated, input/output is locked
⇑ Shift+PgUp/PgDown Scrolls console buffer up/down
Ctrl+C Kills current task
Ctrl+D Inserts an EOF
Ctrl+Z Pauses current Task

Readline

GNU 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 manpage for details).

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+.or_ Paste the last argument of the previous command
History
Ctrl+P Move to the previous line
Altl+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
Altl+? List all possible completions
Alt+* Insert all possible completions

X11

Keyboard Shortcut Description
Ctrl+Alt+F1, F2, F3, ... Switch to n-th virtual console
Shift+Insert
Mouse Button 3
Copy selected text to clipboard, or paste from clipboard

User customization

Readline

This example adds keys that allow (in vi-mode) to search backward through the history for the string of characters between the start of the current line and the point. This is a non-incremental search.

.inputrc
set editing-mode vi
set keymap vi-insert
"\C-r": history-search-backward
"\C-e": history-search-forward

X11

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

Firefox

Use the customizable-shortcuts add-on.

Tips and tricks

Key binding for X-selection-paste

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

Reason: Shift+Insert is a standard shortcut with the same effect, see #X11. (Discuss in Talk:Keyboard shortcuts#)

Users who prefer to work rather with the keyboard 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 "Google search" field.
  3. Hit F12 to paste the buffer, instead of moving the mouse pointer to the field and center-click to paste.

The method suggested here uses three packages available in the official repositories:

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

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

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

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 F12 can be determined using xbindkeys -k.

References:

See also