Emacs lisp: which key was pressed?

Sometime you might want to know which key was pressed last in a lisp function. I came up with this little function for this purpose:

(defun last-key ()
  "Return the last key pressed."
  (car (reverse (append (recent-keys) nil))))

#emacs

↷ 03.08.2017