Keybinding Design is a Linear Programing Problem
2016-08-12 yesterday i realized, that keybinding design is formally a linear programing problem. you have some 100 variables and 100 constraint of equalities and inequalities.
- You have about 80 key positions. (not counting numerical keypad.)
- The set of commands (to be bound to key shortcuts) has a frequency profile. For example, the Copy command is more frequently used than Open file command.
- The set of key positions has a easy-to-press profile. For example, Ctrl+k is more easy to press than Ctrl+z. Ctrl+y is much easier to press than Ctrl+Shift+z.
- The most frequently used commands should bind to the most easy-to-press keys. (this is the goal) For example, Undo has standard shortcut of Ctrl+z, Open has standard shortcut of Ctrl+o, but Undo is much more frequently used than Open, yet the keys Ctrl+z is more difficult to press then Ctrl+o. This is not a optimal keybinding.
- The frequency profile of commands varies by person and operating system (Mac, Windows, Linux) or App. E.g. Depending if you are a heavy photoshop user, or specific 3D modeling app user, or video editing user, or for general web browsing, or if you do a lot programing using a specific editor (emacs/vim/viscode etc). We assume we are not changing the operating system's shortcuts or app's shortcuts.
- Certain modifier keys, such as Ctrl key, must only be in certain places. E.g. It's very bad design to have Ctrl at right hand middle finger on home row. This means, you have a contraint. Only certain key positions can have Ctrl placed.
- Some modifier keys are frequently used together. For example, it's common to have Ctrl+Alt or Ctrl+Shift. This means, there is a constraint, that modifiers usually must be placed together.
- Ctrl is mostly used with a set X of keys, but not other. E.g. Copy (c), paste (v), open (o), new (n), undo (z), redo (y).
- This set X must be in a spots that works with Ctrl as chord hand can easily do. For example, if Ctrl is at normal CapsLock position, then Ctrl+z would be hard to press. If Ctrl is at normal spacebar position, then that is much more optimal.
- You want just 1 Ctrl key if possible, to save key spots. Similar for other modifier such as Shift and Alt.
- Some modifier keys have also leader key sequence purpose, such as Alt key, ▤ Menu key, Compose key.
You want to maximize the overall score, which is the sum of product of key's ease score and its command frequency.
See Emacs vs vim, Compute Keybinding Efficiency