Change your keys
Add a keyPermalink to Add a key#
Every key in Oriel is a binding: a mode, a key sequence and the command it runs. To change NAV keys while keeping the rest, use nav-keymap: with pairs of keys and commands:
(config
nav-keymap: (keys "x" 'tab-close
"C-x k" 'tab-close
"<f12>" 'tab-reopen
"D" #f)
page-keymap: (keys "C-c e" 'edit-url))keys takes a string followed by a command, repeating for each binding. These settings add to the mode's defaults. Repeating a key changes its command, and #f removes that mode's own binding. Here, x closes a tab, D no longer does, and C-x b still opens the tab list: prefixes merge, so adding C-x k keeps the other C-x sequences. Commands you can bind lists every command, and Default keys lists every key Oriel starts with. See Use your password manager for the Linux password keys.
ModesPermalink to Modes#
A binding works in the mode you give it, or through a shared parent. Each mode has a field: nav-keymap:, page-keymap:, pass-keymap:, hint-keymap:, find-keymap: and cmd-keymap:. These are the mode names, the same as the badge in the status bar:
Mode | Badge | When you're in it |
|---|---|---|
| NAV | Browsing. Every key is a command and nothing reaches the page. |
| PAGE | Typing into the page. Keys you haven't bound go to the page. |
| PASS | Every key you haven't bound goes to the page, for sites with their own shortcuts. |
| HINT | Hint labels are showing. |
| FIND | Typing a search for text on the page (Linux and macOS only). |
| CMD | Typing in a prompt: an address, a command or the tab list. |
In PAGE and PASS, a binding takes its keys away from the page. Bind only chords there, like C-x or M-<left>, or you'll find yourself unable to type a letter into a form. How modes work explains how Oriel moves between them.
Common keys and inherited bindingsPermalink to Common keys and inherited bindings#
browser-keymap: supplies common keys to every mode except PASS. Its defaults are ESC, C-g and the Alt-arrow navigation keys. A mode's own binding wins over a common one. Removing an own binding with #f exposes the common binding underneath; use 'ignore to block an inherited key in just one mode.
(config
browser-keymap: (keys "M-<left>" #f
"M-<right>" #f)
page-keymap: (keys "C-g" 'ignore))This removes Alt-arrow navigation from the common map, so PAGE sends those keys to the page. It also makes Control-g do nothing in PAGE. Escape still returns to NAV. HINT's stock map ignores Alt-arrow navigation while you type labels, and PASS has its own Escape binding without a common parent.
Writing keysPermalink to Writing keys#
By default, the arrow keys scroll in NAV. Page Up and Page Down scroll a screen in NAV and move a page through lists. Their binding names are <prior> and <next>. In candidate lists, Up and Down move the highlight; Alt-Up and Alt-Down recall earlier prompt submissions.
Oriel writes keys the way Emacs does. If you've used kbd in an Emacs configuration, you already know it.
A plain character is that key. Capital letters mean Shift, so
"G"is Shift and g.Characters written together are a sequence.
"gg"is g, then g again. Spaces between keys are optional, so"g g"is the same.C-is Control,M-is Alt,S-is Shift ands-is Super."C-x k"is Control and x, then k on its own.Named keys go in angle brackets, in lowercase: <f12>, <left>, <end> and <prior> for Page Up.
Five keys have short names without brackets: RET, SPC, TAB, ESC and DEL.
That last rule has a trap worth knowing about: "End" is three keys, E, n and d, while "<end>" is the End key.
Modifiers must match exactly. A binding for C-r doesn't fire for Control, Alt and r together, and that combination goes on to the page in PAGE mode instead.
Sequences and prefixesPermalink to Sequences and prefixes#
While you're partway through a sequence, Oriel shows what you've typed in the status bar and waits for the rest. A key that doesn't continue any sequence clears it without doing anything, so a mistyped g never runs some other command by accident.
A key can't be both a command and a prefix inside the same keys call. This is an error:
;; Error: is bound to a command, so it can't also be a prefix
(config
nav-keymap: (keys "g" 'top
"gg" 'top))Oriel reports it when it loads your configuration, as it would any other mistake, and starts with its defaults. Duplicate sequences in one keys call are errors too. Across maps, a later command can replace a prefix, or a prefix can replace a command. For example, setting just nav-keymap: (keys "g" 'top) replaces the stock g prefix, including gg, go, gt and gT.
A number typed before a key in NAV mode is a count. 5j scrolls five times as far, and 3gt goes to the third tab.
Replace the whole keymapPermalink to Replace the whole keymap#
Named mode fields are enough for most changes. The earlier bind and add-keys: forms still work: bind takes a mode, key string, command and any arguments, and add-keys: takes a list of those records. When you want a keymap that's mostly your own, keymap: replaces the whole thing. keymap-with builds one from a starting keymap and some bindings, and empty-keymap is a keymap with nothing in it.
Starting from empty-keymap means every key you want, you write. Here's a deliberately small keymap for reading, with a way back to NAV in every mode you can reach:
(config
keymap: (keymap-with empty-keymap
(bind 'nav "j" 'scroll-down)
(bind 'nav "k" 'scroll-up)
(bind 'nav "SPC" 'page-down)
(bind 'nav "o" 'open-prompt)
(bind 'nav "f" 'hints 'follow)
(bind 'nav "b" 'tab-chooser)
(bind 'nav "i" 'page-mode)
(bind 'nav ":" 'command-prompt)
(bind 'page "ESC" 'cancel)
(bind 'hint "ESC" 'cancel)
(bind 'cmd "ESC" 'cancel)))Oriel takes keymap:, applies add-keys:, then merges the named mode fields. This order holds whichever order you write the fields in.
The stash keys in the multi-select list, like C-SPC and M-a, belong to the list itself rather than these mode maps.