Mouse wheel as key on pocketchip keyboard

Beitrag vom 13.08.2017

The PocketCHIP comes with a fully functional keyboard, touchscreen and a USB port. You can simply plug a mouse into the USB port. But I don't want to take a usb mouse with me. The tool xbindkeys allows it to bind the mouse button or the mouse wheel to a keyboard shortcut.

PocketCHIP Keyboard

Alt + V: Mouse middle click (primary selection)
Alt + O: Mouse wheel up
Alt + ; (semicolon): Mouse wheel down

Install xdottol and xbindkeys

sudo apt install xdotool xbindkeys

xdottol allows to emulate keyboard and mouse events by shell commands. So you can "use" the mouse wheel by shell. xbindkeys allows you to bind a keyboard shortcut to a shell command.

Create default config

xbindkeys -d > ~/.xbindkeysrc

Get key codes

Just run xbindkeys -k and hit a keyboard shortcut of your choice.

Scroll up:

chip@chip:~$ xbindkeys -k
Press combination of keys or/and click under the window.
You can use one of the two lines after "NoCommand"
in $HOME/.xbindkeysrc to bind a key.
"(Scheme function)"
    m:0x8 + c:32
    Alt + o

Scroll down:

chip@chip:~$ xbindkeys -k
Press combination of keys or/and click under the window.
You can use one of the two lines after "NoCommand"
in $HOME/.xbindkeysrc to bind a key.
"(Scheme function)"
    m:0x8 + c:60
    Alt + period

Add key bindings

Now open the ~/.xbindkeysrc config file with an editor of your choice and add the new key bindings.

"xdotool click --delay 5 --repeat 3 --clearmodifiers 4"
    m:0x8 + c:32
    Alt + o

"xdotool click --delay 5 --repeat 3 --clearmodifiers 5"
    m:0x8 + c:60
    Alt + period

Test xbindkeys

Start xbindkeys -n to test your configuration. The -n option starts xbindkeys in foreground. You can stop xbindkeys with the keyboard shortcut Ctrl+C.

Autostart xbindkeys

Create a shell script ~/.xsessionrc with the following content:

#!/bin/sh

xbindkeys 
exit 0

Make it executable:

chmod a+x ~/.xsessionrc

The file ~/.xsessionrc will be executed on every X11 launch. A handy solution to start userspace applications after PocketCHIP starts.

Hallo Internet

Mein Name ist Christian, vom Beruf bin ich Anwendungsentwickler.

In meiner Freizeit beschäftige ich mich mit verschiedensten Technologien. Hier sammele ich Dinge, die für mich interessant waren oder sind.