emacs create key modifier

与世无争的帅哥 提交于 2019-12-05 13:57:01

This approach won't make a modifier key in the sense that you press another key with the modifier held down, but it lets you use hyper bindings nevertheless.

By default you can utilise the additional modifier keys via the C-x@ prefix. See C-x@C-h for the full list.

These bindings are in function-key-map, and you can use the same method to get your own OS-independent bindings. e.g.:

(define-key function-key-map (kbd "C-c H") 'event-apply-hyper-modifier)

function-key-map is the parent for all local-function-key-map instances. Note carefully:

Entries in `local-function-key-map' are ignored if they conflict with bindings made in the minor mode, local, or global keymaps. I.e. the remapping only applies if the original key sequence would otherwise not have any binding.

C-hig (elisp) Translation Keymaps RET

So ensure that you use a key sequence with no existing bindings. (In theory that's quite limiting, but YMMV.)

Edit: To clarify, this gives you a way to access any existing 'hyper' bindings when you are using a machine without a hyper modifier key, but does not actually create a new modifier key. If you have no existing bindings to access, this technique has no advantages over a regular prefix binding.

I believe it's the case that, as Peter commented, creating a genuine modifier key is an OS-level task. AFAIK when you press a modifier key on its own, Emacs does not receive any input, and when you press a non-modifier with a modifier, Emacs receives the (modified) input. Conversely when you press/hold a non-modifier key, Emacs receives input immediately, and has no way to combine that input with some other input and treat it all as a single (modified) event.

IIRC, xmodmap would be the typical mechanism for achieving this in Unix systems, so that may well be the case for OSX. The following links may help:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!