You can’t limit the input. (How would you do that, unplug the keyboard, hit the user over their head?) But you can ignore it. Clear the buffer.
Or if as you say you want only the first character, then don’t do it on a loop. Read one character, and not any more.
Maybe all you’re really looking for is: read the whole line. This is easier than figuring out how much input is queued up so if you don’t care beyond that, then look no further. It’s quite likely that you don’t have any need for anything else, because when you see a linebreak then you know you’re in sync (because the user probably types a whole lot slower than you process the input, they won’t have had time to press another key) with the user because the input is line buffered, it’s flushed every time a line ends, the de-sync comes from when the user is typing before having ended the line. Another alternative is to change the buffering mode so that you’re in sync with every key press, but, again, you can’t limit the input, there can always be purposefully badly formed input.