in reply to hit ENTER in the keyboard
Sounds like you need a robotic arm with either an IP or serial interface :)
Your question is woefully lacking in details. What you really want to do is send either a LF or a CR-LF to some process, presumably one currently selected in a GUI. The problem is that in most cases (at least for unix), the pipes between the keyboard input and STDIN for the connected application may not be writeable by other processes. There are a few CPAN modules that support keyboard input interception. You could then act as a kind of proxy and inject extra data whenever you want.