For search&destroy: check names that override ROM functions such as "cd", "startup", "rm", "edit" etc.
Then you can open the files using the Fs API, and read the whole file into a string, which can be scanned for malicious commands such as "os.shutdown()" using the String API, and then removed using the Fs api again.
For pressing keys: Ctrl-T does that, but you would need to have an "os.pullEvent" or "os.pullEventRaw" in your program, since a key press is an event.
The "key" event returns the keycode of the key pressed, and if it's equal to the keycode of the esc key you know it's pressed.
I don't know the Esc keycode, but it's simple to get.
Write a program like this, run it and press any key to get the keycode returned.
local param = nil
while param == nil do
event, param = os.pullEvent("key")
end
return param
This should work.
If I stated anything incorrectly, feel free to correct me. I'm only getting started as well, after all.