Emacs: Bind Number Pad Keys

By Xah Lee. Date: . Last updated: .
pc keyboard

See that large useless number pad on your keyboard? It's your best friend. It adds 17 programable keys!

For example, key to List Buffers, open bookmark.

;; bind number pad keys

(global-set-key (kbd "<kp-1>") 'bookmark-bmenu-list)
(global-set-key (kbd "<kp-2>") 'ibuffer)

To use, be sure the number lock is on.

Note: On the Mac, defining keys for the numeric keypad will not work. You need to use some keymap tool first to make them send numpad key signals. [see Mac: Key Remapping and Keybinding Tools]

If you run emacs in terminal, numberpad may not work.

More examples:

;; number pad keys

(global-set-key (kbd "<kp-decimal>") 'other-window)
(global-set-key (kbd "<kp-0>") 'delete-window)
(global-set-key (kbd "<kp-1>") 'delete-other-windows)
(global-set-key (kbd "<kp-2>") 'split-window-below)
(global-set-key (kbd "<kp-3>") 'xah-open-file-at-cursor)

(global-set-key (kbd "<kp-subtract>") 'xah-close-current-buffer)
(global-set-key (kbd "<kp-divide>") 'xah-previous-user-buffer)
(global-set-key (kbd "<kp-multiply>") 'xah-next-user-buffer)

;; with control key down
(global-set-key (kbd "<C-kp-divide>") 'xah-previous-emacs-buffer)
(global-set-key (kbd "<C-kp-multiply>") 'xah-next-emacs-buffer)

You can also use the numberpad keys for outside of emacs. See:

If you don't have a numberpad and want to buy one:

Emacs Keybinding Tips

  1. Add Custom Keys to Enhance Productivity
  2. isearch by Arrow Keys
  3. Bind Number Pad Keys
  4. 1 Key for M-x
  5. Hotkey to Open File Fast
  6. Add Web Browser Back Key/Button to Info mode
  7. Ctrl+x and Dvorak

If you have a question, put $5 at patreon and message me.
Or Buy Xah Emacs Tutorial
Or buy a nice keyboard: Best Keyboards for Emacs

Emacs

Emacs Lisp

Misc