Use keys for mouse buttons on linux. Alternative to AHK?
On windows I have an autohotkey script which:
- Only works when caps lock is on
- Generates left, middle and right mouse button events when left control, menu and alt keys are pressed
- Allows holding the keys down (for dragging objects)
Is there an easy way of duplicating this functionality in linux?
linux keyboard mouse macros
add a comment |
On windows I have an autohotkey script which:
- Only works when caps lock is on
- Generates left, middle and right mouse button events when left control, menu and alt keys are pressed
- Allows holding the keys down (for dragging objects)
Is there an easy way of duplicating this functionality in linux?
linux keyboard mouse macros
add a comment |
On windows I have an autohotkey script which:
- Only works when caps lock is on
- Generates left, middle and right mouse button events when left control, menu and alt keys are pressed
- Allows holding the keys down (for dragging objects)
Is there an easy way of duplicating this functionality in linux?
linux keyboard mouse macros
On windows I have an autohotkey script which:
- Only works when caps lock is on
- Generates left, middle and right mouse button events when left control, menu and alt keys are pressed
- Allows holding the keys down (for dragging objects)
Is there an easy way of duplicating this functionality in linux?
linux keyboard mouse macros
linux keyboard mouse macros
edited Jul 22 '11 at 21:05
Gilles
52.1k14113161
52.1k14113161
asked Jul 22 '11 at 19:16
typist
262
262
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
X has a built-in mechanism for controlling the mouse cursor with the keyboard. Press the
Pointer_EnableKeys
key to activate this mode (mouse keys mode); it's usually bound to Shift+NumLock.
In mouse keys mode, the keypad arrows move the pointer around, and the other keypad keys emulate buttons (/*-
are left, middle, right respectively; +
is left double-click, and 0
and .
are left press and release).
See mouse keys for more information. By the way, this mode can be enabled on Windows too.
Thanks, but I'm afraid mousekeys won't work because I still use the mouse in my right hand to move the cursor. And even if I could reassign the keys used by the mousekeys program, I would have to explicitly change between left, middle or right. With my ahk script I can rest my fingers on the three keys and press any or a combination of them instantly.
– typist
Jul 22 '11 at 21:47
add a comment |
You could probably do the same things with Tcl ('tickle').
add a comment |
Keymapping - mouse click - middle click
How to Map Mouse buttons to Keyboard keys
Firstly, disable keypad controlling mouse so xev can capture the keycode
Then type the command:
$ xev
Then move your mouse into the little new window that pops up.
Press a mouse button to find out the name of that button:
See below, I found one of my mouse buttons is called "button 1"
ButtonPress event, serial 37, synthetic NO, window 0x6200001,
root 0x29d, subw 0x6200002, time 2427401, (31,41), root:(652,407),
state 0x0, button 1, same_screen YES
Then find out which keyboard key you want to map that mouse button to:
Press a keyboard key and find the keycode.
When pressing the space key on my keyboard, the terminal shows:
KeyPress event, serial 37, synthetic NO, window 0x6200001,
root 0x29d, subw 0x0, time 2152399, (398,60), root:(1019,426),
state 0x0, keycode 65 (keysym 0x20, space), same_screen YES,
XLookupString gives 1 bytes: (20) " "
XmbLookupString gives 1 bytes: (20) " "
XFilterEvent returns: False
from above, we have found that the keycode for the Space key is 65
So you need to find the keycodes of the keys you want to map mouse buttons to...
Then the next step:
$ sudo apt-get install xkbset
Then copy the script below and save it into a file called keymap_mouse2kb.sh
of course change the keyboard keycodes to the ones you want
#!/bin/bash
# set XKB layout
setxkbmap -layout us
# turn on mousekeys
xkbset m
# stop mousekeys expiring after a timeout
xkbset exp =m
# map keysym to other keysym
#xmodmap -e "keysym Menu = Pointer_Button2"
# this also works
xmodmap -e "keycode 66 = Pointer_Button2"
xmodmap -e "keycode 133 = Pointer_Button1"
xmodmap -e "keycode 88 = Pointer_Button3"
Then make this file executable by
$ sudo chmod u+x keymap_mouse2kb.sh
Then run it when you need it... e.g. at booting up
$ ./keymap_mouse2kb.sh
"setxkbmap -layout us" - does this imply that this might only work with 1 layout?
– Sarge Borsch
Oct 27 at 11:31
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f313926%2fuse-keys-for-mouse-buttons-on-linux-alternative-to-ahk%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
X has a built-in mechanism for controlling the mouse cursor with the keyboard. Press the
Pointer_EnableKeys
key to activate this mode (mouse keys mode); it's usually bound to Shift+NumLock.
In mouse keys mode, the keypad arrows move the pointer around, and the other keypad keys emulate buttons (/*-
are left, middle, right respectively; +
is left double-click, and 0
and .
are left press and release).
See mouse keys for more information. By the way, this mode can be enabled on Windows too.
Thanks, but I'm afraid mousekeys won't work because I still use the mouse in my right hand to move the cursor. And even if I could reassign the keys used by the mousekeys program, I would have to explicitly change between left, middle or right. With my ahk script I can rest my fingers on the three keys and press any or a combination of them instantly.
– typist
Jul 22 '11 at 21:47
add a comment |
X has a built-in mechanism for controlling the mouse cursor with the keyboard. Press the
Pointer_EnableKeys
key to activate this mode (mouse keys mode); it's usually bound to Shift+NumLock.
In mouse keys mode, the keypad arrows move the pointer around, and the other keypad keys emulate buttons (/*-
are left, middle, right respectively; +
is left double-click, and 0
and .
are left press and release).
See mouse keys for more information. By the way, this mode can be enabled on Windows too.
Thanks, but I'm afraid mousekeys won't work because I still use the mouse in my right hand to move the cursor. And even if I could reassign the keys used by the mousekeys program, I would have to explicitly change between left, middle or right. With my ahk script I can rest my fingers on the three keys and press any or a combination of them instantly.
– typist
Jul 22 '11 at 21:47
add a comment |
X has a built-in mechanism for controlling the mouse cursor with the keyboard. Press the
Pointer_EnableKeys
key to activate this mode (mouse keys mode); it's usually bound to Shift+NumLock.
In mouse keys mode, the keypad arrows move the pointer around, and the other keypad keys emulate buttons (/*-
are left, middle, right respectively; +
is left double-click, and 0
and .
are left press and release).
See mouse keys for more information. By the way, this mode can be enabled on Windows too.
X has a built-in mechanism for controlling the mouse cursor with the keyboard. Press the
Pointer_EnableKeys
key to activate this mode (mouse keys mode); it's usually bound to Shift+NumLock.
In mouse keys mode, the keypad arrows move the pointer around, and the other keypad keys emulate buttons (/*-
are left, middle, right respectively; +
is left double-click, and 0
and .
are left press and release).
See mouse keys for more information. By the way, this mode can be enabled on Windows too.
answered Jul 22 '11 at 21:04
Gilles
52.1k14113161
52.1k14113161
Thanks, but I'm afraid mousekeys won't work because I still use the mouse in my right hand to move the cursor. And even if I could reassign the keys used by the mousekeys program, I would have to explicitly change between left, middle or right. With my ahk script I can rest my fingers on the three keys and press any or a combination of them instantly.
– typist
Jul 22 '11 at 21:47
add a comment |
Thanks, but I'm afraid mousekeys won't work because I still use the mouse in my right hand to move the cursor. And even if I could reassign the keys used by the mousekeys program, I would have to explicitly change between left, middle or right. With my ahk script I can rest my fingers on the three keys and press any or a combination of them instantly.
– typist
Jul 22 '11 at 21:47
Thanks, but I'm afraid mousekeys won't work because I still use the mouse in my right hand to move the cursor. And even if I could reassign the keys used by the mousekeys program, I would have to explicitly change between left, middle or right. With my ahk script I can rest my fingers on the three keys and press any or a combination of them instantly.
– typist
Jul 22 '11 at 21:47
Thanks, but I'm afraid mousekeys won't work because I still use the mouse in my right hand to move the cursor. And even if I could reassign the keys used by the mousekeys program, I would have to explicitly change between left, middle or right. With my ahk script I can rest my fingers on the three keys and press any or a combination of them instantly.
– typist
Jul 22 '11 at 21:47
add a comment |
You could probably do the same things with Tcl ('tickle').
add a comment |
You could probably do the same things with Tcl ('tickle').
add a comment |
You could probably do the same things with Tcl ('tickle').
You could probably do the same things with Tcl ('tickle').
answered Jul 22 '11 at 23:05
paradroid
19.1k95898
19.1k95898
add a comment |
add a comment |
Keymapping - mouse click - middle click
How to Map Mouse buttons to Keyboard keys
Firstly, disable keypad controlling mouse so xev can capture the keycode
Then type the command:
$ xev
Then move your mouse into the little new window that pops up.
Press a mouse button to find out the name of that button:
See below, I found one of my mouse buttons is called "button 1"
ButtonPress event, serial 37, synthetic NO, window 0x6200001,
root 0x29d, subw 0x6200002, time 2427401, (31,41), root:(652,407),
state 0x0, button 1, same_screen YES
Then find out which keyboard key you want to map that mouse button to:
Press a keyboard key and find the keycode.
When pressing the space key on my keyboard, the terminal shows:
KeyPress event, serial 37, synthetic NO, window 0x6200001,
root 0x29d, subw 0x0, time 2152399, (398,60), root:(1019,426),
state 0x0, keycode 65 (keysym 0x20, space), same_screen YES,
XLookupString gives 1 bytes: (20) " "
XmbLookupString gives 1 bytes: (20) " "
XFilterEvent returns: False
from above, we have found that the keycode for the Space key is 65
So you need to find the keycodes of the keys you want to map mouse buttons to...
Then the next step:
$ sudo apt-get install xkbset
Then copy the script below and save it into a file called keymap_mouse2kb.sh
of course change the keyboard keycodes to the ones you want
#!/bin/bash
# set XKB layout
setxkbmap -layout us
# turn on mousekeys
xkbset m
# stop mousekeys expiring after a timeout
xkbset exp =m
# map keysym to other keysym
#xmodmap -e "keysym Menu = Pointer_Button2"
# this also works
xmodmap -e "keycode 66 = Pointer_Button2"
xmodmap -e "keycode 133 = Pointer_Button1"
xmodmap -e "keycode 88 = Pointer_Button3"
Then make this file executable by
$ sudo chmod u+x keymap_mouse2kb.sh
Then run it when you need it... e.g. at booting up
$ ./keymap_mouse2kb.sh
"setxkbmap -layout us" - does this imply that this might only work with 1 layout?
– Sarge Borsch
Oct 27 at 11:31
add a comment |
Keymapping - mouse click - middle click
How to Map Mouse buttons to Keyboard keys
Firstly, disable keypad controlling mouse so xev can capture the keycode
Then type the command:
$ xev
Then move your mouse into the little new window that pops up.
Press a mouse button to find out the name of that button:
See below, I found one of my mouse buttons is called "button 1"
ButtonPress event, serial 37, synthetic NO, window 0x6200001,
root 0x29d, subw 0x6200002, time 2427401, (31,41), root:(652,407),
state 0x0, button 1, same_screen YES
Then find out which keyboard key you want to map that mouse button to:
Press a keyboard key and find the keycode.
When pressing the space key on my keyboard, the terminal shows:
KeyPress event, serial 37, synthetic NO, window 0x6200001,
root 0x29d, subw 0x0, time 2152399, (398,60), root:(1019,426),
state 0x0, keycode 65 (keysym 0x20, space), same_screen YES,
XLookupString gives 1 bytes: (20) " "
XmbLookupString gives 1 bytes: (20) " "
XFilterEvent returns: False
from above, we have found that the keycode for the Space key is 65
So you need to find the keycodes of the keys you want to map mouse buttons to...
Then the next step:
$ sudo apt-get install xkbset
Then copy the script below and save it into a file called keymap_mouse2kb.sh
of course change the keyboard keycodes to the ones you want
#!/bin/bash
# set XKB layout
setxkbmap -layout us
# turn on mousekeys
xkbset m
# stop mousekeys expiring after a timeout
xkbset exp =m
# map keysym to other keysym
#xmodmap -e "keysym Menu = Pointer_Button2"
# this also works
xmodmap -e "keycode 66 = Pointer_Button2"
xmodmap -e "keycode 133 = Pointer_Button1"
xmodmap -e "keycode 88 = Pointer_Button3"
Then make this file executable by
$ sudo chmod u+x keymap_mouse2kb.sh
Then run it when you need it... e.g. at booting up
$ ./keymap_mouse2kb.sh
"setxkbmap -layout us" - does this imply that this might only work with 1 layout?
– Sarge Borsch
Oct 27 at 11:31
add a comment |
Keymapping - mouse click - middle click
How to Map Mouse buttons to Keyboard keys
Firstly, disable keypad controlling mouse so xev can capture the keycode
Then type the command:
$ xev
Then move your mouse into the little new window that pops up.
Press a mouse button to find out the name of that button:
See below, I found one of my mouse buttons is called "button 1"
ButtonPress event, serial 37, synthetic NO, window 0x6200001,
root 0x29d, subw 0x6200002, time 2427401, (31,41), root:(652,407),
state 0x0, button 1, same_screen YES
Then find out which keyboard key you want to map that mouse button to:
Press a keyboard key and find the keycode.
When pressing the space key on my keyboard, the terminal shows:
KeyPress event, serial 37, synthetic NO, window 0x6200001,
root 0x29d, subw 0x0, time 2152399, (398,60), root:(1019,426),
state 0x0, keycode 65 (keysym 0x20, space), same_screen YES,
XLookupString gives 1 bytes: (20) " "
XmbLookupString gives 1 bytes: (20) " "
XFilterEvent returns: False
from above, we have found that the keycode for the Space key is 65
So you need to find the keycodes of the keys you want to map mouse buttons to...
Then the next step:
$ sudo apt-get install xkbset
Then copy the script below and save it into a file called keymap_mouse2kb.sh
of course change the keyboard keycodes to the ones you want
#!/bin/bash
# set XKB layout
setxkbmap -layout us
# turn on mousekeys
xkbset m
# stop mousekeys expiring after a timeout
xkbset exp =m
# map keysym to other keysym
#xmodmap -e "keysym Menu = Pointer_Button2"
# this also works
xmodmap -e "keycode 66 = Pointer_Button2"
xmodmap -e "keycode 133 = Pointer_Button1"
xmodmap -e "keycode 88 = Pointer_Button3"
Then make this file executable by
$ sudo chmod u+x keymap_mouse2kb.sh
Then run it when you need it... e.g. at booting up
$ ./keymap_mouse2kb.sh
Keymapping - mouse click - middle click
How to Map Mouse buttons to Keyboard keys
Firstly, disable keypad controlling mouse so xev can capture the keycode
Then type the command:
$ xev
Then move your mouse into the little new window that pops up.
Press a mouse button to find out the name of that button:
See below, I found one of my mouse buttons is called "button 1"
ButtonPress event, serial 37, synthetic NO, window 0x6200001,
root 0x29d, subw 0x6200002, time 2427401, (31,41), root:(652,407),
state 0x0, button 1, same_screen YES
Then find out which keyboard key you want to map that mouse button to:
Press a keyboard key and find the keycode.
When pressing the space key on my keyboard, the terminal shows:
KeyPress event, serial 37, synthetic NO, window 0x6200001,
root 0x29d, subw 0x0, time 2152399, (398,60), root:(1019,426),
state 0x0, keycode 65 (keysym 0x20, space), same_screen YES,
XLookupString gives 1 bytes: (20) " "
XmbLookupString gives 1 bytes: (20) " "
XFilterEvent returns: False
from above, we have found that the keycode for the Space key is 65
So you need to find the keycodes of the keys you want to map mouse buttons to...
Then the next step:
$ sudo apt-get install xkbset
Then copy the script below and save it into a file called keymap_mouse2kb.sh
of course change the keyboard keycodes to the ones you want
#!/bin/bash
# set XKB layout
setxkbmap -layout us
# turn on mousekeys
xkbset m
# stop mousekeys expiring after a timeout
xkbset exp =m
# map keysym to other keysym
#xmodmap -e "keysym Menu = Pointer_Button2"
# this also works
xmodmap -e "keycode 66 = Pointer_Button2"
xmodmap -e "keycode 133 = Pointer_Button1"
xmodmap -e "keycode 88 = Pointer_Button3"
Then make this file executable by
$ sudo chmod u+x keymap_mouse2kb.sh
Then run it when you need it... e.g. at booting up
$ ./keymap_mouse2kb.sh
answered Jun 7 at 4:00
Russo
1012
1012
"setxkbmap -layout us" - does this imply that this might only work with 1 layout?
– Sarge Borsch
Oct 27 at 11:31
add a comment |
"setxkbmap -layout us" - does this imply that this might only work with 1 layout?
– Sarge Borsch
Oct 27 at 11:31
"setxkbmap -layout us" - does this imply that this might only work with 1 layout?
– Sarge Borsch
Oct 27 at 11:31
"setxkbmap -layout us" - does this imply that this might only work with 1 layout?
– Sarge Borsch
Oct 27 at 11:31
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f313926%2fuse-keys-for-mouse-buttons-on-linux-alternative-to-ahk%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown