How to manipulate keyboard input in console
I'm making a C program that works as a bot on a text-mode web browser. The program navigates on web pages and reads stuff from them.
Since making a set of pipes for both reading and writing to and from the browser which my program calls, seems a bit challenging for me, I've come to the conclusion that one handy way of making this work is to, according to desired keys to be pressed, put stuff into stdin. In other words: I want to manipulate keyboard input without actually having to press the keys on the keyboard.
How do I do this?
I understand this may be quite dependent on the platform. However, I don't intend to distribute my program. I'm an Ubuntu user.
So to make the story easier, I want to have a function like the following example:
where 56 would be either ascii or keycode. The program wouldn't know if it's me pressing a certain key on the keyboard or if I called the press_key function instead.