For source code, check out this project’s GitHub page: https://github.com/SSODelta/keyboard-control

I like to play piano, and sometimes I like to watch videos on Youtube while I’m playing. However, it gets kind of tedious having to switch back and forth between my computer and my piano, so I decided to challenge myself making a program, which enables me to control my computer from my keyboard.

I found some code on StackOverflow, which makes it possible to listen to the input from a MIDI device. I then took this code and incorporated it with the Robot-class in java.awt.*, which makes it possible emulate keyboard presses and mouse clicks.

Currently, you have to hold down the low A (the lowest note on my piano) and press some of the buttons to move the mouse, click etc.

Keys:

F2 – Move mouse slightly left

– Move mouse slightly left F#2 – Move mouse slightly up

– Move mouse slightly up G2 – Move mouse slightly down

– Move mouse slightly down G#2 – Move mouse slightly right

– Move mouse slightly right Bb2 – Page Up

Page Up B2 – Page Down

– Page Down C3 – Move mouse left

– Move mouse left C#3 – Move mouse up

– Move mouse up D3 – Move mouse down

– Move mouse down D#3 – Move mouse right

– Move mouse right E3 – Left click

– Left click F3 – Right click

– Right click F#3 – Enter

– Enter G3 – Space

– Space G#3 – Escape

I plan to make more commands soon (including New Tab, Close Tab, and others), but as of now, this will do.

This is one of the simplest programs I’ve made recently, but I just like it’s application.