I'm writing some code where I have to identify the command for the last key pressed. Sometimes I need to look up a combination of this key with another one. I use the
key-binding function for that. It works most of the time but not for all keys. For example it does not work for the backspace key:
(progn (read-key) (key-binding (vector last-input-event))) ;; > nil for backspace
I can work around this by checking for backspace manually but I wonder if there is a more reliable way that works for all/most situations?
last-input-event because it is after exiting a keymap through the default binding
Based on the accepted answer I'm using something like the following which seems to work very well:
(progn (read-key) (key-binding (kbd (edmacro-format-keys (vector last-input-event)))))