improved keyPressed by using a hash map for key codes.