Next: Accessing Mouse, Previous: Event Examples, Up: Input Events [Contents][Index]
Every event has an event type, which classifies the event for key binding purposes. For a keyboard event, the event type equals the event value; thus, the event type for a character is the character, and the event type for a function key symbol is the symbol itself. For events that are lists, the event type is the symbol in the CAR of the list. Thus, the event type is always a symbol or a character.
Two events of the same type are equivalent where key bindings are concerned; thus, they always run the same command. That does not necessarily mean they do the same things, however, as some commands look at the whole event to decide what to do. For example, some commands use the location of a mouse event to decide where in the buffer to act.
Sometimes broader classifications of events are useful. For example, you might want to ask whether an event involved the META key, regardless of which other key or mouse button was used.
The functions event-modifiers
and event-basic-type
are
provided to get such information conveniently.
This function returns a list of the modifiers that event has. The
modifiers are symbols; they include shift
, control
,
meta
, alt
, hyper
and super
. In addition,
the modifiers list of a mouse event symbol always contains one of
click
, drag
, and down
. For double or triple
events, it also contains double
or triple
.
The argument event may be an entire event object, or just an
event type. If event is a symbol that has never been used in an
event that has been read as input in the current Emacs session, then
event-modifiers
can return nil
, even when event
actually has modifiers.
Here are some examples:
(event-modifiers ?a) ⇒ nil (event-modifiers ?A) ⇒ (shift) (event-modifiers ?\C-a) ⇒ (control) (event-modifiers ?\C-%) ⇒ (control) (event-modifiers ?\C-\S-a) ⇒ (control shift) (event-modifiers 'f5) ⇒ nil (event-modifiers 's-f5) ⇒ (super) (event-modifiers 'M-S-f5) ⇒ (meta shift) (event-modifiers 'mouse-1) ⇒ (click) (event-modifiers 'down-mouse-1) ⇒ (down)
The modifiers list for a click event explicitly contains click
,
but the event symbol name itself does not contain ‘click’.
This function returns the key or mouse button that event
describes, with all modifiers removed. The event argument is as
in event-modifiers
. For example:
(event-basic-type ?a) ⇒ 97 (event-basic-type ?A) ⇒ 97 (event-basic-type ?\C-a) ⇒ 97 (event-basic-type ?\C-\S-a) ⇒ 97 (event-basic-type 'f5) ⇒ f5 (event-basic-type 's-f5) ⇒ f5 (event-basic-type 'M-S-f5) ⇒ f5 (event-basic-type 'down-mouse-1) ⇒ mouse-1
This function returns non-nil
if object is a mouse movement
event.
This function converts a list of modifier names and a basic event type to an event type which specifies all of them. The basic event type must be the last element of the list. For example,
(event-convert-list '(control ?a)) ⇒ 1 (event-convert-list '(control meta ?a)) ⇒ -134217727 (event-convert-list '(control super f1)) ⇒ C-s-f1
Next: Accessing Mouse, Previous: Event Examples, Up: Input Events [Contents][Index]