Have it detect key presses. Think of it this way: When a user presses the 'A' key in a video game, the program runs code; don't think of it as receiving input. Think of it as detecting keystrokes and adding each keystroke to some data structure (e.g. an array).
I am familiar with the functionality in UNIX terminal that you are talking about and it doesn't allow you to backspace or anything. If you want that functionality, just do what I said above.
If you want to be able to backspace, although the user won't be able to see what they backspace, you can write code that removes the last element of the array when the user clicks backspace.
Also, everyone else is correct when they say that you will need to program this specific to the system you're running it on.
Lastly, this might not be secure if you are using this for a password and just throwing it into an array.