' Utility to print information about pressed keyboard buttons.
'

MainLoop:
    ' Wait for a key press and store it in userInput$
    userInput$ = INKEY$

    ' If no key has been pressed, jump back to the main loop
    IF userInput$ = "" THEN GOTO MainLoop

    ' Print the character that was typed by the user
    PRINT "You typed: "; userInput$

    ' Calculate the ASCII value of the first character (if input is more than one character)
    ' and print it
    IF LEN(userInput$) > 0 THEN
        PRINT "ASCII value of the first character ('"; LEFT$(userInput$, 1); "'): "; ASC(LEFT$(userInput$, 1))
    END IF

    ' Calculate the ASCII value of the last character and print it
    IF LEN(userInput$) > 0 THEN
        PRINT "ASCII value of the last character ('"; RIGHT$(userInput$, 1); "'): "; ASC(RIGHT$(userInput$, 1))
    END IF

    ' Jump back to the main loop to wait for another key press
    GOTO MainLoop