Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: key bindings table?

On Feb 22, 10:35am, Ray Andrews wrote:
} Do we have a key bindings table that translates all the various ways of 
} referring to a key press?

You can generate one for your terminal/keyboard combo by running the
"zkbd" utility.  As you noticed, $terminfo (from zsh/terminfo module)
sometimes has useful definitions but it's more interested in what the
terminal understands for cursor motion than what the keyboard sends
for input.

There's documentation for zkbd in the manual.  (If someone feels like
extending zkbd to cover the keypad, jump right in.)

} For example, in 'zbindkey' we have this sort of thing:
}    [[ "$terminfo[kend]"  == "O"* ]] &&
}    bindkey -M emacs "${terminfo[kend]/O/[}"  end-of-line

I'm not sure which "zbindkey" this refers to.  It's not something that
is distributed with zsh.

} "^E" end-of-line
} "^[OF" end-of-line
} "^[[F" end-of-line
} ... so I trust that one of those lines refers to the 'End' key. Which one?

Two of them do, in this case.  Keyboards can be in two states, usually
called "normal mode" and "keypad transmit mode" and the End key sends
different sequences depending on which mode is in effect.  ^E is the
usual emacs end-of-line binding, the other two are End key values.

} Is there a table? Or some other way of being able to pick a keystroke 
} and know how to refer to it in " terminfo[] " ... in " 
} bindkey-in-zbindkey " ... in  "bindkey-at-CLI " and/or in whatever other 
} languages there may happen to be?

There are too many interchangable combinations of keyboards and terminals
(and operating systems) to create a table that covers them all.  The zkbd
utility covers the most common ones (plus some from old Sun keyboards
that are a lot less common now) but far from everything.  The manual for
terminfo (not zsh's manual for the zsh/terminfo module) usually includes
a table of the most standard names for display actions, which as mentioned
covers some key-driven cursor motions, but also covers all sorts of other
display actions that have nothing to do with the keyboard.

On top of this you have terminal emulators which often have the ability
to redefine all of the keys.  Graphical interfaces receive "scan codes"
based on the keyboard layout, but CLI programs don't see them, they can
only use the character sequences that the emulator generates based on the
scan code it receives.

DOS was simple because it was Microsoft and IBM everywhere, and it all
used the raw scan codes.

Barton E. Schaefer

Messages sorted by: Reverse Date, Date, Thread, Author