Partial solution: ESC key
is equivalent to M-key
, so you can type Escape key instead of Alt+key if that's more convenient. If you don't use Menu for anything in Emacs, you can make it an alternate ESC
. You'd have to type Menu then the key instead of using it as a modifier.
(define-key function-key-map [menu] [?\e])
An approximately equivalent solution would be
(define-key function-key-map [menu] 'event-apply-meta-modifier)
This one generalizes to other modifiers but has the downsides that it plays tricks with the event loop and that makes it fail rarely, but confusingly (because diagnostic messages will display the applied modifier but some of the lower layers of Emacs won't see it).
Here's a slightly more complex variant that allows keeping the key down, i.e. you can press and hold Menu, then press another key and release both. However, if you want to type two Alt+key successively, you'll still have to release Menu and press it back between the two keys, because Emacs doesn't react to key-up events.
(defun event-force-meta-modifier (_ignore-prompt)
(let ((event (read-event)))
(message "event = %S" event)
(while (eq (lookup-key function-key-map (vector event)) 'event-force-meta-modifier)
(message "event = %S" event)
(setq event (read-event)))
(vector (event-apply-modifier event 'meta 27 "M-"))))
event-force-meta-modifier
(define-key function-key-map [menu] 'event-force-meta-modifier)