how can I stop the input of the keyboard for a user

I want that everytime the user press a key the program read what key was and only accept some keys that I want