system doesn't work like that. You may want to use IPC::Open3 instead, but note that not every program will cooperate with it, and keylogging is not something many people here will be interested in sharing info about.
I'll tak a look at IPC::Open3.
I agree with the sentiment towards keylogging. This isn't a keylogger, per se. It's just a script that will execute some code once a certain key combination has been entered. The end users are fully aware of its presence, and its pretty much the whole reason for using the system.