DRY, bitch

Factorised some stuff
Did a little workaround to use the keyboard as input
Renamed a few variables