Is there a way to mimic "click and drag" using the keyboard?

5,625

Using xdotool

Not really convenient, but possible: with xdotool, you can simulate mouse- and keyboard events:

  1. Install xdotool:

    sudo apt-get install xdotool
    
  2. Now you need to add two keyboard shortcuts; one to simulate pressing the left mouse button, and one to release it:

    Choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:

    xdotool mousedown 1
    

    to (e.g.) Super + ,

    and

    xdotool mouseup 1
    

    to (e.g.) Super + .

Now you can drag by placing the cursor on the item, press Ctrl + ,, move the item and press Ctrl + . to "drop" the item.

Share:
5,625

Related videos on Youtube

Reagankm
Author by

Reagankm

Updated on September 18, 2022

Comments

  • Reagankm
    Reagankm over 1 year

    I'm running Ubuntu 15.10 on an old 2008 MacBook. My trackpad had an unfortunate accident (prolonged exposure to condensation) and no longer recognizes the "drag" portion when I'm trying to click and drag. Other than that it works fine. It lets me move the mouse, click, or scroll pages with no problems but for some reason if I try to drag it just moves the mouse without invoking "drag" functionality.

    Is there a way to set up a hot key so if I click and hold down Shift, for example, then the computer will treat further mouse movements like a click and drag?

  • Reagankm
    Reagankm over 8 years
    Awesome! This works really well. Thank you so much. :]
  • Jacob Vlijm
    Jacob Vlijm over 8 years
    @Lyrric cool! always glad if it works :)