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 Keyboard Software Guide]

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:

ErgoEmacs mascot-s276x226
Buy Xah Emacs Tutorial

Emacs Keys



Key Tips

Emacs Pinky

Keybinding Design