The following code allows me to catch an escape key press. After evaluating the code, pressing ESC will print "Escape pressed", as desired.
Unfortunately, due to the equivalence between ESC and Meta, Meta keys do not function when this keymap is active. Instead, I see messages like
M-f is undefined
I would like to be able to evaluate the following block of code, press M-f, and have it invoke forward-word
as usual. Is there any way to achieve this?
(set-transient-map
`(keymap
(27 . ,(lambda () (interactive) (message "Escape pressed"))))
nil (lambda () (message "Other key pressed")))