Let me break the snippet down so you can understand what it’s doing.
IF LEN(k$) THEN <— This checks to see if we have a keypress
IF k$ = CHR$(8) AND LEN(mymessage$) <> 0 THEN. <— This checks to see if the key pressed was the BACKSPACE key, and if we have a string of any size
mymessage$ = LEFT$(mymessage$, LEN(mymessage$) - 1). <— Here, if we have a string, and hit backspace, we erase the last character in that string.
ELSE. <— else we have a key pressed, and it’s not the backspace key, or we don’t have a existing string for mymessage$
IF LEN(k$) = 1 AND ASC(k$) >= 32 THEN mymessage$ = mymessage$ + k$ <— This basically says if the key is CHR$(32) or higher, add it to our string, as long as it’s not a control key like the 2-digit arrow keys.
END IF. <— To end the IF...ELSE...block to check for backspace
END IF. <— To end the check for key presses.
So basically, we check for a keypress. If backspace is pressed, we erase the last character from our string. Otherwise, as long as it’s not a control key, we add it to our string.
That’s what the above does for us.