I normally use emacs (on Linux) running in windowing mode. I have bound a number of functions to special keypresses such as <C-return> and <kp-add>.

Ocasionally, I'm forced to run emacs in a text console, where some of the keypresses cannot be detected.

Is there a way I can tell a console-based emacs, "Pretend I just pressed <kp-add>"?


For keys which a terminal can't even send unmodified (which I suspect is the case with <kp-add>), you will need to bind some key which can be sent by the terminal.

You can bind a key to the keyboard macro [kp-add] in order that the alternative key sequence does whatever <kp-add> would have done:

(global-set-key (kbd "C-c p") (kbd "<kp-add>"))

You could even call a macro without a key binding:

M-: (execute-kbd-macro (kbd "<kp-add>")) RET

Alternatively, you could use function-key-map (or the terminal-local local-function-key-map) to directly map the key sequences like so:

(define-key function-key-map (kbd "C-c p") (kbd "<kp-add>"))

in which case Emacs translates C-c p to <kp-add> (as opposed to calling a macro which in turn simulates typing <kp-add>).

In practice, both methods ought to do the job.

<C-return> would be similar, but C-RET can be sent via event-apply-control-modifier like so:


If the terminal can send the unmodified key, you can use this approach to send a modified variant. Type C-x@C-h for the list of supported modifiers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.