0

I would like to setup keyboard shortcuts with other keys that traditional modifier keys, as modifier keys.

example : bind "f1-left" ( so F1+) to a command.

But not bind the sequence F1 to the command like explained in this answer : Using function keys as "sticky" modifier keys

is that something possible in emacs ?

I see commands such as

(define-key function-key-map [f8] 'event-apply-super-modifier) but is there a command binding on press and on release events ? like a "define-key-press" "define-key-release" ? If so we could bind a command event-apply-super-modifier when f1 is pressed and event-release-super-modifier when f1 is released.

1

You currently cannot do that within Emacs (at least, not without changing Emacs's C code).
We could expose the "press" and "release" events on keyboard keys, but we don't do that so far.

OTOH, you can do it outside of Emacs with xmodmap (or its more modern replacement, IIRC it'd be something like setxkbmap).

E.g. something like:

xmodmap -e 'add mod4 F1'

after which you can do

(global-set-key [H-left] 'my-favorite-command-for-f1-left)
| improve this answer | |
  • You might want to mention that xmodmap and setxkbmap might not be available on all platforms. – Drew Sep 20 '19 at 15:36

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.