You will want to look into the curses library. There are versions for most Unix-like systems, as well as for console programs on Windows (and probably programs running PowerShell, but not sure).
This library has functions for reading keystrokes, moving around the screen and drawing window borders using ASCII characters or terminal graphics in an independent platform / terminal. Some versions even have the ability to work with mice.
There are many more curses that can help you, but it will be difficult for you to understand this until you read more about it and see some examples in action (and you really understand that they use curses).
The most popular version for free * nix systems is ncurses, and the Windows version is called pdcurses.
source share