Reputation: 41
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
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