How to enable input for only specific characters?

How did you create the files in the middle? Sorry I’m a total noob and I’m trying to find how to use specific keys to possess specific characters like 1 for the first 2 for the second 3 for the third 4 for the fourth and 5 for the fifth. Thanks in advance!