Thinkpiece: optimal global keyboard shortcuts

From razwiki
Jump to navigation Jump to search

A modern operating system desktop environment can have many levels of nested applications when it comes to keyboard shortcuts. There's the core kernel keybinding handling (for example, control+alt+delete), base operating system (windows+d), background keyboard mapping application (autohotkey, powertoys), background application (tabby focusing itself with control-space) focused application (brave control+t), extension (vimium d), and view keybinding (alt-shift-s to save mediawiki page). The editing area can also have its own set of text editing commands (like mac control+r) and modals (insert emoji).

All these applications share 1 input device: the keyboard. As for the physical keyboard, it has multiple modes of input: function modifier implemented on the device (operating system does not see function key press), modifiable keyboard layouts, keyboard device macros, unusual keys (print screen, media keys), mode keys (numloc), modifiers (control does nothing when pressed alone by default), and I'm choosing to ignore fancy methods of input like a touchbar. Applications like karabiner-elements seem to do their work using a virtual keyboard anyways; perhaps hammerspoon talks directly to the operating system.

Communicating intent to the computer

Ideally, one could take an action, and see what exa

ctly the computer saw, and what the computer decided to do with it. For example, I could hit control+r and the computer could say:

- I saw you press control down at 12:12:00.583

- I saw you press r at ... .0132 seconds later

- I passed the keypress "control+r" to the application "Brave" with pid 1381 at ... .007 seconds later

And then Brave would have a similar keybinding manager (or at least log user actions)

- I received the keybinding "control+r"

- I looked up the keyboard shortcut in this keyboard mapping: { ... }

- I found the binding brave.page.reload (or whatever)

- I sent a brave.page.reload event to tab 1 which was at http://yourpage.com

- (ui log) I blanked the page

- (network log) I opened a connection to ...

- (ui log) page ... finished loading

It gets tricky with js, because a page usually implements js with addEventListener, which listens for all events, and then rolls its own keyboard manager / imports one, and what exactly happens is kind of a mystery. But theoretically there could be a standard for document.registerKeyboardShortcut or something, then the document's keyboard shortcuts could be queried.

I credit emacs C-h k describe key with giving me an idea of what's possible - that prompts the user for an action, and upon receiving an action, shows the name of the command, where it is bound, and links to the source code of the function. Very useful for hacking! Since a lot of useful commands can be reduced to a couple of keyboard shortcuts (something like go to start of line, press space 4 times, restore cursor position) would be nice for ad-hoc indenting.

Ah, another thing that's annoying. Websites like StackOverflow rebind keyboard shortcuts like C-b to make text bold, so when I'm trying to move my cursor left, I get ** bold text ** markers which I don't want. I can intercept this action by rebinding control-b to <left arrow> but it's not ideal - I'm losing the disambiguation between control-b and left arrow, and if I don't remap on a per-application basis, it affects other applications. Ideally such an overwriting would only affect that one website.

Some fertile ground for keybindings

Thumb keys are much easier on my fingers than pinky keys. Often I use my left ring finger rather than my left pinky, since it's so weak and overused. The following left pinky keys can be reassigned thusly:

escape: hit left alt and no other key to send escape.

- there is an annoying thing here; when I'm in an html text area, escape loses the focus, which is really annoying to get back. I should make a refocus extension and keep track of the cursor position, then allow a single keyboard shortcut to put the focus back.

` is easily pressable by left ring finger.

tab is sometimes remapped as control-i, and I can reach a control key with my right thumb. Probably there's a better way to do this.

As I type this, I realize that shift keys are kinda hard on my pinkies; perhaps <space-p> could be remapped to P, but that has the potential for weird typos. Worth a shot.

Honestly I feel like the super cool split ergonomic keyboards could lean into that kind of keybinding more, and less so moving expected keys places. Though I guess something like keyboardio uses a thumb key for shift, much like this spacebar idea.

Maybe a "conventional" keyboard could include a little thumb control key. There's also foot pedals, though I'm skeptical they're that convenient. Probably actually pretty reasonable to pull off.

Most of the time, things like capitalization can be figured out through software. i by itself can often be capitalized to I, and the user could do things like ii to mean "capital I" or lowercase I, but with some nuance taken for words that might have multiple "i"s in a row, like roman numerals. Stuff gets complicated.

I'm reminded of the story of how I basically beat rsi, not by buying a new keyboard, but by limiting my working hours to 4 and remapping all the keyboard shortcuts that used my pinkies / awkward hand positions / anything other than spacemacs-style modal keyboard shortcuts. That modal stuff is so good! Gems of keyboard shortcuts like

- space space

- space backspace

- space return

- control-space space

- shift space

- space escape

- space f prefix for file commands

- space '

- space ,

- g space

- space tab

- automatically doing stuff like formatting text, to save a lot of typing...

- Making cli workflows that automatically reload stuff, so that building can be done with 1 or even 0 commands, ideally something far downstream like "control r to reload" or just save on emacs losing focus (alt tab becomes the "build" key).

Another thing I think we've unfortunately lost track of is the utility of "hard" keyboard keys, like the power key. If I use it now it goes blank, if I hold it it goes blank immediately too, ideally I could use it like any other key and do shift-power to logout or something. Or just skip the key since its hardware-y and use keyboard shortcuts like windows-l to lock the screen.