Computer Keyboard: Using Number Keypad as Function Keys

, , …,

A lot programers don't like the numeric keypad, because they never use it, and it makes reaching the mouse more difficult.

Actually, the numeric keypad is the best thing, because you can use them as extra function keys. This adds 16 programable keys to your keyboard, and as part of your keyboard, not a separate piece of keypad hardware. You just need to use a tool to remap them.

here's the tools and howto.

Microsoft Windows

For Microsoft Windows, the best tool is AutoHotkey. I've been using AutoHotkey for many years.

pc keyboard
the numeric keypad of a standard PC keyboard

here's AHK examples:

;; NumpadSub decrease sound volume, NumpadAdd increase sound volume
$NumpadAdd::Send {Volume_Up 5} ; increase sound level
$NumpadSub::Send {Volume_Down 5} ; decrease sound level
;; Mozilla Firefox

#IfWinActive ahk_class MozillaWindowClass

$F2::Send ^x ; cut
$F3::Send ^c ; copy
$F4::Send ^v ; paste

NumpadDiv::Send ^{PgUp} ; previous tab
NumpadMult::Send ^{PgDn} ; next tab
NumpadSub::Send ^w ; close window

$Del::Send ^w ; close window
;; Second Life

#IfWinActive ahk_class Second Life

NumpadSub::Send ^w ; close window

NumpadDiv::Send !{Left} ; previous tab
NumpadMult::Send !{Right} ; next tab

Numpad1::Send ^!+9 ; show hide volume (objects)
Numpad3::Send ^!+= ; show/hide particles
Numpad4::Send ^+r ; show hide wireframe
Numpad5::Send ^+f ; show/hide friend list
Numpad6::Send ^!t ; show/hide alpha (transparent) objects
Numpad8::Send ^h ; show/hide local chat
Numpad9::Send ^+a  ; Emerald toggle sim radar; or who's nearby

detail at:

Linux

sun keyboard num
the numeric keypad on Sun Microsystems Type 6 Keyboard

For Linux, depending on what Desktop or window manager you are using (Gnome, KDE, Ubuntu Unity, Xfce, xmonad, …), you can usually set a key to do window manipulation (switch, close, maximize, …) or launch app or run terminal commands, in the system preference.

one issue is that if you assign it to launch a app, it usually launch new, not switch to a existing one. But often, you can set a key to switch to last app, as if pressing 【Alt+Tab ↹】 once (this is the most useful. Some 70% of the time you just need to switch to last app.). Again, the exact detail depends on what window manager you are using. Else, you'll have to spend time into key configuration (again, depending on what linux distro you are using).

xfce window manager keys setup  2013-06-07
xfce window manager keys setup

For a short intro and list of tools, see: Linux: Keyboard Layout, Keymapping, Keybinding, Tools ⌨

Mac

Apple iMac Keyboard A1243-numpad
Numpad on Apple Keyboard. amazon img src

For Mac, by default, it's impossible to make the number pad do anything other than inputting numbers, because OS X does remapping at some low level. Some tool lets you do it though, see: Mac OS X Keyboard Layout, Keymapping, Keybinding, Tools.

Emacs

If you use emacs, you are in luck! Because emacs has the most robust and extensive ways to remap keys. And you can use it across Windows & Linux.

however, if you run emacs in terminal, it may not work. Also, on the Mac, it may not work.

here's a example:

;; NUMBERIC KEYPAD. nice number pad conveniences as extra function keys

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

(global-set-key (kbd "<C-kp-divide>") 'ergoemacs-previous-emacs-buffer)
(global-set-key (kbd "<C-kp-multiply>") 'ergoemacs-next-emacs-buffer)

(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-vertically)
(global-set-key (kbd "<kp-3>") 'xah-open-file-at-cursor)

(global-set-key (kbd "<kp-9>") 'isearch-forward)

(defun xah-isearch-hook ()
  "Hook for `isearch-mode-hook'"
  (define-key isearch-mode-map (kbd "<C-kp-9>") 'isearch-repeat-backward)
  (define-key isearch-mode-map (kbd "<kp-9>") 'isearch-repeat-forward)
  (define-key isearch-mode-map (kbd "<C-f7>") 'isearch-repeat-backward)
  (define-key isearch-mode-map (kbd "<f7>") 'isearch-repeat-forward)
  )
(add-hook 'isearch-mode-hook 'xah-isearch-hook)

detai at

Don't Have a Number Pad?

If you don't have number pad, then you might want to get a dedicated keypad. I recommend Logitech G13.

logitech g13 gameboard 2-s
“Logitech G13 Advanced Gameboard” 1500×1500 amazon

one advantage of using this is that you don't have to spend hours in a programing language to config the keys. With the Logitech G13, it has on-board memory, and easy-to-use Graphical User Interface software to set the keys. Once set, you can plug it in any computer and work as expected. Also, G13 lets you switch profiles, so you can have one for Windows, Mac, Linux, at work, home.

Full review at Logitech G13 Advanced Gameboard Review.

or, you might try this:

XK-24 USB programmable keypad 71426
《XK-24 USB programmable keypad》 amazon imc src

the shape of this keypad is very good for programing, as opposed to gamer use as in Logitech G13. However, it tends to be more expensive, due to lack of popularity and competition.

more options at Add Extra Function Keys to Your Keyboard

blog comments powered by Disqus