Emacs: How to Define Super Hyper Keys

By Xah Lee. Date: . Last updated: .

This page shows you how to define ❖ SuperHyper keys in emacs.

Emacs supports extra modifier keys called Super & Hyper. These keys are from lisp keyboard.

Symbolics's lisp machine keyboard PN 365407 Rev C. (Photo by Joey Devilla. Used with permission.) 〔➤see Space-cadet Keyboard and Lisp Machine Keyboards〕.

You can set Hyper & Super to PC keyboard's ❖ Win key or the ▤ Menu key, or Apple Keyboard's ⌥ option key.

Why Use Super & Hyper?

The advantage of creating the ❖ SuperHyper in emacs is that you can have more hotkeys, and no major or minor modes will stamp on your keys. For example, ❖ Super for all your personal hotkeys, or for entering math symbols or Unicode. 〔➤see How to Create a APL or Math Symbols Keyboard Layout ⌨

Setting Up Super & Hyper Keys

Microsoft Windows

;; make PC keyboard's Win key or other to type Super or Hyper, for emacs running on Windows.
(setq w32-pass-lwindow-to-system nil)
(setq w32-lwindow-modifier 'super) ; Left Windows key

(setq w32-pass-rwindow-to-system nil)
(setq w32-rwindow-modifier 'super) ; Right Windows key

(setq w32-pass-apps-to-system nil)
(setq w32-apps-modifier 'hyper) ; Menu/App key

(info "(emacs) Windows Keyboard")

Note: in Microsoft Windows, several keybindings with the Windows key is bound at a low level, and applications do not see them. For example, 【❖ Win+r】 is for launching apps by command name. 〔➤see Windows Logo Key Keyboard Shortcuts〕 There's no way around that unless you use other tools such as AutoHotkey. 〔➤see AutoHotkey Tutorial〕 Even so, it may not be possible to disable 【❖ Win+l】 (lock window). (registry edit may not work)

for more advanced keyboard tools for Microsoft Windows, see: Windows: Keyboard Layout Tools, Key Macro Tools ⌨

Mac OS X

;; set keys for Apple keyboard, for emacs in OS X
(setq mac-command-modifier 'meta) ; make cmd key do Meta
(setq mac-option-modifier 'super) ; make opt key do Super
(setq mac-control-modifier 'control) ; make Control key do Control
(setq ns-function-modifier 'hyper)  ; make Fn key do Hyper

Note: if you set ⌘ Cmd or Fn key, some of their Mac function remains. For example, 【⌘ Cmd+Tab ↹】 still do switch app, and Fn key can still be used as the modifier for multimedia keys. Thanks to jcs, see 〔A Hyper Key for the Mac By Jon Snader. @ http://irreal.org/blog/?p=1450

See also:


By default, the ❖ Win key is ❖ Super.

On Linuxes, you should define ❖ SuperHyper key in the OS. For example, in Ubuntu 11.04, it's under 〖System ▸ Preferences ▸ keyboard〗 then “Layout” tap, “Options…” button.

Note that some Linux or the Desktop/WindowManager pre-defines some ❖ Super key. You need to take them off before emacs can see it. Best way to check is simply try define the key in emacs first and see if it works.

For more advanced settings, see: Linux Keybinding Tutorial Index ⌨

Defining Super & Hyper Keybinding

Use H for Hyper, s for Super.

;; examples of keybinding with hyper or super key

(global-set-key (kbd "H-b") 'backward-word) ; H is for hyper
(global-set-key (kbd "s-b") 'backward-word) ; lower case “s” is for super

(global-set-key (kbd "M-H-b") 'backward-word) ; Meta+Hyper+b
(global-set-key (kbd "M-s-b") 'backward-word) ; Meta+Super+b

  ;; some Hyper keys to insert Unicode chars
  (define-key key-translation-map (kbd "H-3") (kbd "•")) ; bullet
  (define-key key-translation-map (kbd "H-4") (kbd "◇")) ; white diamond
  (define-key key-translation-map (kbd "H-5") (kbd "†")) ; dagger

For more detail, see Emacs: How to Define Keys.

Key Ghosting Warning

Be aware that most keyboards won't be able to detect certain combination of keys. This is called key ghosting.

For example, on Microsoft Natural Ergonomic 4000 keyboard, the key 【▤ Menu+RShift+x】 does not register (but with left Shift it does). So, if you have set ▤ Menu to do Hyper, then Hyper+X with right ⇧ Shift won't work.

Vast majority of keyboards have ghosting problem, including Apple keyboards. For detail, see: What's NKRO, N-key Rollover? .

Like it? Buy Xah Emacs Tutorial. Thanks.