How to change a button colour

hi does anyone know how to change the colour of a button when we push a key

example

press left key only the left side of the colour change and when release it will change be to the default colur and so goes to right key only the right side will change