Scrolling on FreeBSD with the arrow keys

I recently acquired a HP EliteBook 9470m (before you ask: it's personal), and installed FreeBSD on it. The Synaptics touchpad is detected on FreeBSD as a PS/2 mouse on both laptops, and unlike the 2570p I was coming from, the 9470m doesn't automatically fallback to edge scrolling. While web browsers make up by making it easy to scroll with the arrow keys, other applications (such as email) end up doing actions you might not want with the arrow keys.

Here comes (not to be confused with the jQuery plugin Scrollify). It works alongside xbindkeys to emulate scrolling with the up/down keys.

Since is not yet on FreeBSD Ports, you will have to install it manually.


First, you need py-xlib and pip. To install this, run either:

pkg install py27-pip py27-xlib


cd /usr/ports/devel/python-pip
make config-recursive install clean
cd /usr/ports/x11-toolkits/py-xlib
make config-recursive install clean

in a root shell.

Then you need to install the Python module pynput. This is used for controlling the keyboard and mouse from Python, and is not in Ports either. To install this, run this as a normal user:

pip install --user pynput

Next, you will need xbindkeys in order to do the mapping. To install this, run:

pkg install xbindkeys


cd /usr/ports/x11/xbindkeys
make config-recursive install clean

Finally, you should install somewhere on your system. For example, if you want it in ~/.local/bin:

mkdir -p ~/.local/bin
cd ~/.local/bin
fetch --no-verify-peer


You will need to modify .xbindkeysrc. To do that, run:

vim ~/.xbindkeysrc

and add the following:

"python ~/.local/bin/ up"
  alt + Up

"python ~/.local/bin/ down"
  alt + Down

Replace vim with your text editor of choice, ~/.local/bin to the place you stored, and alt + Up and alt + Down to your desired key combination (you can Google search the possible combinations). This will map the scroll up to Alt + Up and scroll down to Alt + Down.

You finally need to make your window manager or desktop environment (GNOME for me) launch xbindkeys on startup. For instance, on GNOME, make the directory ~/.config/autostart if it doesn't exist, create a .desktop file in the directory with the following content:

[Desktop Entry]
GenericName=Keyboard Bindings

On your specific WM or DE, this can be found on the Internet. Arch Linux's wiki has a page on startup scripts for all the major DEs (and I believe the information should be common on FreeBSD as well).

I may update this page once or pynput makes it to FreeBSD Ports (I am a maintainer), but in the meanwhile, that's it.

Also, for the JavaScript hipsters: no, I'm not going to join you and become a 'web developer'. I tried many years ago, but I don't think it's really 'me'.