The problem can/could be, that you didn't know if your Mac was asleep or just in screen-off mode but still awake, so pressing a key might or might not have sent a keystroke or mouse click to whichever window was open.
It doesn't matter if the computer is fully asleep or just the display is asleep- pressing a key once will only wake it up and will not register in any application.