Thanks to MD XF's recent challenge, we can now read passwords in many different languages! The problem is, now we need to port our applications to mobile devices, and they do password entry a little differently.
- Read a string from the keyboard.
- Each time a character
kis entered, display it for a short time interval.
- After the time interval has passed OR the user has entered another character, replace
kwith some character
cmust be constant; it must be the same character.
ccan be any visible character (i.e. it cannot be a newline, space, tab, or unprintable).
ccan't be based on any inputted
cmust be defined/constant before the first
cmust be the same every time the program is run.
ccan be one of the values given as
kif by accident, as long as all other rules are followed.
- You must print
kin realtime. As soon as the user enters a new
k, you must display it immediately.
kshould be visible to the end user before being changed to
c; the time interval shall not be less than 0.5 seconds.
kshould be replaced by
cwithin a reasonable time; the time interval shall not exceed 5 seconds.
- As soon as a new character is entered, whether or not the time interval has expired, you should replace
cand use the entered key as the new
- It is acceptable to clear and redraw the screen each time you need to change a character.
- You may use any reasonable methods of input and output as long as all other rules are followed.
- You may assume that the number of characters inputted is never longer than the terminal/graphical window width.
- If using a terminal, your program should terminate after a newline is entered or EOF is reached.
- Your program should function as outlined here on both mobile and other environments.
- Your program may assume that the input will only contain printable characters (letters, numbers, symbols) and possibly a terminating newline (no backspace, arrow keys, delete, etc).
- Your program may terminate when Ctrl+C is pressed.
- You may terminate your program by closing a window, if your program launches one.
This is code-golf, so the shortest answer in each language wins!
Here is an example of what it should look like. Note this is recorded on a mobile platform, but should also work on a desktop platform.