Function: event-modifiers

event-modifiers is a byte-compiled function defined in subr.el.gz.

Signature

(event-modifiers EVENT)

Documentation

Return a list of symbols representing the modifier keys in event EVENT.

The elements of the list may include meta, control, shift, hyper, super, alt, click, double, triple, drag, and down. EVENT may be an event or 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 this function may fail to include the click modifier.

View in manual

Probably introduced at or before Emacs version 19.20.

Source Code

;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defun event-modifiers (event)
  "Return a list of symbols representing the modifier keys in event EVENT.
The elements of the list may include `meta', `control',
`shift', `hyper', `super', `alt', `click', `double', `triple', `drag',
and `down'.
EVENT may be an event or 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 this function may fail to include
the `click' modifier."
  (declare (side-effect-free t))
  (unless (stringp event)
    (let ((type event))
      (if (listp type)
	  (setq type (car type)))
      (if (symbolp type)
          ;; Don't read event-symbol-elements directly since we're not
          ;; sure the symbol has already been parsed.
	  (cdr (internal-event-symbol-parse-modifiers type))
        (let ((list nil)
	      (char (logand type (lognot (logior ?\M-\0 ?\C-\0 ?\S-\0
                                                 ?\H-\0 ?\s-\0 ?\A-\0)))))
	  (if (not (zerop (logand type ?\M-\0)))
	      (push 'meta list))
	  (if (or (not (zerop (logand type ?\C-\0)))
		  (< char 32))
	      (push 'control list))
	  (if (or (not (zerop (logand type ?\S-\0)))
		  (/= char (downcase char)))
	      (push 'shift list))
	  (or (zerop (logand type ?\H-\0))
	      (push 'hyper list))
	  (or (zerop (logand type ?\s-\0))
	      (push 'super list))
	  (or (zerop (logand type ?\A-\0))
	      (push 'alt list))
	  list)))))