How to print something if player presses keys in order on the table

I would make a string and whenever a player presses a button it adds that button to the string, then use string.sub to see if “print” for example is inside of the string.