DawgBone
DawgBone

Reputation: 41

Emacs - how to determine if the control key is down

I want an Emacs Lisp function to have two different behaviors depending on whether the control key is pressed or not.

Is there a way to query the state of the control key? Thanks.

Upvotes: 4

Views: 298

Answers (1)

Stefan
Stefan

Reputation: 28541

There's no facility to check the current state of a modifier key, but you can check whether the last key used to run the command was used with "control" or not:

(memq 'control (event-modifiers last-command-event))

Note that TAB and RET are actually the same as C-i and C-m, so they are considered as having a "control" modifier.

Upvotes: 2

Related Questions