fix input key press

To sum up, the simulation of the key event can be left as it is. 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.