I am working on a kind of typing practice application.
There will be some text on the screen. What I want to do is just remove the characters (starting from the beginning) if the user presses the right one.
For example:
(output screen)
This is some sample text
Error count: 0
*when the user presses 'T'*
his is some sample text
Error count: 0
*when the user presses 'h'*
is is some sample text
Error count: 0
*if the user presses the wrong one, it adds up in the error count*
like, *if the user presses 'm'*
is is some sample text
Error count: 1
---------------------------------
Currently the code removes the correctly typed characters from the output text. Maybe changing their color would be even better.
Using this way, the user has to press 'Enter' after the input of a character every time. So, the question is how can the input be extracted from the buffer without pressing enter? Like whenever the user presses any character, the code can automatically take action and update the screen accordingly. Can this be done using event/key listeners or is there any other method?
There will be some text on the screen. What I want to do is just remove the characters (starting from the beginning) if the user presses the right one.
For example:
(output screen)
This is some sample text
Error count: 0
*when the user presses 'T'*
his is some sample text
Error count: 0
*when the user presses 'h'*
is is some sample text
Error count: 0
*if the user presses the wrong one, it adds up in the error count*
like, *if the user presses 'm'*
is is some sample text
Error count: 1
---------------------------------
Currently the code removes the correctly typed characters from the output text. Maybe changing their color would be even better.
Using this way, the user has to press 'Enter' after the input of a character every time. So, the question is how can the input be extracted from the buffer without pressing enter? Like whenever the user presses any character, the code can automatically take action and update the screen accordingly. Can this be done using event/key listeners or is there any other method?
Comment