The solution is using inkey, not inchar, and checking the number of entered characters.