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 open List Buffers, 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. [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:

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. Emacs: How to Define Keys
  2. Emacs: Change Major Mode Keys
  3. Emacs: Change Minor Mode Keys
  4. Emacs: Fix Minor Mode Key Priority
  5. Emacs: Define Key Sequence
  6. Emacs: How to Bind Super Hyper Keys
  7. Emacs: How to Define Menu Key
  8. Emacs: Remapping Keys Using key-translation-map
  9. Emacs: Bind Number Pad Keys
  10. Emacs: 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.