2

Is there any way to bind the meta key (a.k.a. super key / Windows key) to a left click using xbindkeys? I would like that hitting the meta key triggers a left click, and hold down the meta key allows to drag and drop (just like it would do when holding down left click).

1

This is possible. The following will disable the super key and rebind it to the left mouse button. If you wish to preserve the functionality of the super key while also binding to the left mouse button, check out this question.

There seem to be some issues with xbindkeys when we use a modifier key to trigger mouse or keyboard events, so we will first rebind the super key to a non-modifier key using xmodmap.

First, determine the keycode and keysym of your super key using xbindkeys --key, and substitute these values in the commands below. Example output, indicating keycode 134 and keysym Super_R:

m:0x50 + c:134
Mod2+Mod4 + Super_R

Remove the super key from the modifier map:

xmodmap -e 'remove mod4 = Super_R'

Rebind the super key to an unused keysym (in this example, F13):

xmodmap -e 'keycode 134 = F13'

Disable autorepeat for the rebinded key:

xset -r 134

Finally, install xdotool and add the following to ~/.xbindkeysrc to configure xbindkeys (xte or another virtual input program can be used instead of xdotool):

"xdotool mousedown 1"
  F13
"xdotool mouseup 1"
  F13 + release

Now simply kill any existing xbindkeys instance and run xbindkeys. The super key will behave as a left mouse button.

Note that these settings are not preserved across sessions. To set things up automatically, run the following at the start of each session (along with starting xbindkeys):

xmodmap -e 'remove mod4 = Super_R' -e 'keycode 134 = F13' && xset -r 134
  • Great answer! Does this answer your question Frank? – holmb Oct 13 '16 at 9:10
  • Would it be possible to add the mouse binding without removing the original keyboard binding? Thank you! – Dakatine Apr 18 '18 at 10:35

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.