SXEmacs provides some auxiliary functions for converting between events and other ways of representing keys. These are useful when working with ascii strings and with keymaps.
This function converts a keystroke description to an event structure. key-description is the specification of a key stroke, and event is the event object to fill in. This function contains knowledge about what the codes “mean”—for example, the number 9 is converted to the character <Tab>, not the distinct character <Control-I>.
Note: key-description can be an integer, a character, a symbol such as
clearor a list such as(control backspace).If optional arg event is non-
nil, it is modified; otherwise, a new event object is created. In both cases, the event is returned.Optional third arg console is the console to store in the event, and defaults to the selected console.
If key-description is an integer or character, the high bit may be interpreted as the meta key. (This is done for backward compatibility in lots of places.) If use-console-meta-flag is
nil, this will always be the case. If use-console-meta-flag is non-nil, themetaflag for console affects whether the high bit is interpreted as a meta key. (Seeset-input-mode.) If you don't want this silly meta interpretation done, you should pass in a list containing the character.Beware that
character-to-eventandevent-to-characterare not strictly inverse functions, since events contain much more information than the ascii character set can encode.
This function returns the closest ascii approximation to event. If the event isn't a keypress, this returns
nil.If allow-extra-modifiers is non-
nil, then this is lenient in its translation; it will ignore modifier keys other than <control> and <meta>, and will ignore the <shift> modifier on those characters which have no shifted ascii equivalent (<Control-Shift-A> for example, will be mapped to the same ascii code as <Control-A>).If allow-meta is non-
nil, then the <Meta> modifier will be represented by turning on the high bit of the byte returned; otherwise,nilwill be returned for events containing the <Meta> modifier.If allow-non-ascii is non-
nil, then characters which are present in the prevailing character set (see variablecharacter-set-property) will be returned as their code in that character set, instead of the return value being restricted to ascii.Note: specifying both allow-meta and allow-non-ascii is ambiguous, as both use the high bit; <M-x> and <oslash> will be indistinguishable.