refactor initialization code into function
refactor into buildKeypressTuple
fix checkChar bug