How to send keystrokes to Chrome in Ubuntu?

You could use xdotool Install xdotool

while true; do
   xdotool key Escape
   sleep 120
done

You can specify a window with the --window option