I have written a source code for my users. At the start of the code it prompts users' inputs.
The problem is, whenever they source the code, the focus is still in the source editor, such that some of them ended up typing their inputs in the source without noticing that. When they are aware of themselves not typing anything in the console, they move the focus themselves, without being aware of that they have already changed the source, and somehow saved it later unintentionally. The next time they run it, there are errors due to what they did to the source codes.
I know cat("\014")
works like Ctrl+L to clear the console.
Though, what is the command that works like Ctrl+2 which is the shortcut that moves the focus to the console? In fact, is there a way to simulate specified key press in R?