Due to large quantities of Chocolate Cake falling on my computer's touchpad it has become unresponsive at times (though the left- and right-click works fine) and I would like to make it so that when I press CTRL and at the same time hold down one or two of the arrow keys for the mouse to move accordingly. So if the up-arrow key is pressed it will move up, if the left-arrow key, then left, and so, and if the right-arrow key and the top-arrow keys are being help down together for it to move diagonally (and so on for the rest of the keys).
I am running Ubuntu GNOME 15.10 with GNOME 3.18, can this be done? And if so how? I would accept a script which does this.
Best Answer
Scripted alternative to Universal access (to move the mouse)
Not 100% exactly like you describe, nevertheless an alternative for using the mouse or touchpad. The answer below in fact is an almost exact copy of an answer I posted a long time ago on this question. I deleted it however, since I never had the chance to find out if it was what OP was looking for (no response at all).
In your case, since you only want to use it to move the mouse, you can leave out a number of shortcut keys (the last three) which will also prevent the most "risky" options. The scripted options should work fine any way, without risks on conflicting situations.
Mouse Keys alternative
As mentioned, the script offers basic mouse functionality, as an alternative to the default Mouse Keys- option in System Settings > Universal Access. Unlike Mouse Keys, the mouse pointer is moved (either x- or y wise) by repeated clicks, in two modes:
To my own surprise, I found it reasonably comfortable to use. It is definitely not the same level as a "real" mouse, but (much) more comfortable than the use of Mouse Keys, at least in my experience. After five minutes to get used to it, I was able to perform practically all "normal" actions; opening applications, drag windows, edit text etc.
Disadvantage
There is however a downside to mention:
Unlike Mouse Keys, the setup does not "claim" the NumPad exclusively. The disadvantage of that is that there is a bigger chance of key clashes, especially with the left/right click and hold the left click -functionality. Although I did not run into insurmountable situations, you might run into some conflicts, and being familiar with general shortcut keys is an advantage.
You will have to try and see if it works for you.
The setup
The script needs xdotool:
Disable mouse keys (most likely it already is)
Copy the script below into an empty file, save it as
mouse
(no extension) in~/bin
(create the directory if needed).Make the script executable.
~/bin
, either log out/in, or runsource ~/.profile
, to make the directory "visible" in$PATH
.Now add a number of shortcut keys. All shortcut keys as I set it up are aiming on the use of the NumPad, in combination with Shift+Ctrl (fast move), Ctrl (slow move, mouse left click), Ctrl+Super, (right click, mouse down).
Add the following shortcut keys: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the commands (11 in total, including mouse keys):
key combination: Shift+Ctrl+Num Left
key combination: Shift+Ctrl+Num Right
key combination: Shift+Ctrl+Num Up
key combination: Shift+Ctrl+Num Down
And:
key combination: Ctrl+Num Left
key combination: Ctrl+Num Right
key combination: Ctrl+Num Up
key combination: Ctrl+Num Down
Additionally, I set shortcut keys for:
left-click:
key combination: Ctrl+*
right-click:
key combination: Ctrl+Super+*)
hold left click (e.g. to grab, use click to release):
key combination: Ctrl+Super+/)