@Ra7eN
To just tweak it a little for backspace, and leave the door open for other tweaks, like arrow keys, home/end, etc...
Pete
To just tweak it a little for backspace, and leave the door open for other tweaks, like arrow keys, home/end, etc...
Code: (Select All)
PRINT "-Enter Password: ";: pInput$ = silentInput$
PRINT pInput$ 'DEBUG DELETE AFTER TESTING
FUNCTION silentInput$
DIM Txt$
DIM KeyPress$
Txt$ = ""
' GREAT FOR PASSWORDS
'------------------------------------------------------------------------------------------------
pw = 1 ' Zero to show keyboard typing or 1 to show only asterisks.
start_column = POS(0)
y = CSRLIN: x = POS(0) ' Initial cursor position.
DO
_LIMIT 30
KeyPress$ = INKEY$
IF LEN(KeyPress$) THEN
string_position = POS(0) - start_column ' Track cursor and word position.
SELECT CASE KeyPress$
CASE CHR$(27) ' Esc key.
SYSTEM
CASE CHR$(13) ' Enter key.
EXIT DO
CASE CHR$(8) ' Backspace key.
IF string_position > 0 THEN
Txt$ = MID$(Txt$, 1, string_position - 1) + MID$(Txt$, string_position + 1)
LOCATE , start_column: PRINT SPACE$(LEN(Txt$) + 1);
LOCATE , start_column
IF pw THEN PRINT STRING$(LEN(Txt$), "*"); ELSE PRINT Txt$;
LOCATE , x - 1
END IF
CASE CHR$(32) TO "z"
IF pw THEN PRINT "*"; ELSE PRINT KeyPress$;
Txt$ = Txt$ + KeyPress$
END SELECT
y = CSRLIN: x = POS(0) ' Track cursor.
END IF
LOOP
'------------------------------------------------------------------------------------------------
PRINT
silentInput$ = Txt$
END FUNCTION
Pete