Firstly, please follow this advice so that we can correctly interpret the structure of your code:
Secondly, it is likely that the issue is that you are comparing to numeric values like 2 when you actually mean to compare to a string value like '2'. i.e. for the purposes of getting a response from the keyboard, the '2' key is just a letter or symbol like any other key. It isn’t a numeric value, and so needs to be in quotes.