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)

For more about defining keys, see:

Emacs: How to Define Keys

You can also use the numberpad keys for system-wide operation. See:

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

Emacs Keybinding How-To Topic

  1. How to Define Keys
  2. Change Major Mode Keys
  3. Change Minor Mode Keys
  4. Fix Minor Mode Key Priority
  5. Define Key Sequence
  6. How to Bind Super Hyper Keys
  7. How to Define Menu Key
  8. Remapping Keys Using key-translation-map
  9. Bind Number Pad Keys
  10. How to Set Mouse Buttons
Patreon me $5 patreon

Or Buy Xah Emacs Tutorial

Or buy a nice keyboard: Best Keyboard for Emacs

If you have a question, put $5 at patreon and message me.