I want to map, remap or create a shortcut that:

F1 : Right click

F2 : Left click

F3 : Scroll Down

F4 : Scroll Up


I used xmodmap and xdotool, and I made the best use of them. xmodmap is better for left and right click. Shortcut using xdotool is better for scroll down and up.

I will show all steps to let the user decide which keys and buttons they want to remap.

0 - Discover keys names

With xev you discover:

F1 : keycode 67

F2 : keycode 68

F3 : keycode 69

F4 : keycode 70

Left click: Pointer_Button1

Right click: Pointer_Button3

Scroll Down: Pointer_Button5

Scroll Up: Pointer_Button6

1 - Use F1 and F2 to left and right click

Use xmodmap to really remap keys (better than shortcuts, because it allows drag and drop)

xmodmap -e "keycode 67 = Pointer_Button3"
xmodmap -e "keycode 68 = Pointer_Button1 Pointer_Button1"

This solution derived partially from here.

2 - Create shortcuts for scroll down and up

keyboard > shortcuts > "+" > ...

Scroll down and shortcut F3

xdotool click 5

Scroll up and shortcut F4

xdotool click 4

Restore default configuration of xmodmap:

setxkbmap -option
  • This is great, really, but now I have my keypad off. How to map F1/F2 keys as clicks and be able to use numeric keypad please ? Jan 29 '19 at 15:14
  • @MévatlavéKraspek unfortunatelly I still dont have the answer... I simply stopped using keypad... If you find the solution please share. Jan 30 '19 at 0:10
  • How to map middle mouse button (pressing scroll wheel)?
    – blueray
    Jul 20 '19 at 16:57
  • 1
    @blueray I had to use a python script to do it. I used pyautogui. I didnt find anything only using bash. Jul 20 '19 at 17:43

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.