Event listener

make the palette input event handler code a little easier to comprehend