fix input key press

To sum up, the simulation of the key event can get simpler. We just need to make sure the key is sent to the correct target, which is entirely determined by the previous click step. Check out the two lines of comments.