Flexible Windows

version 13/130803 by Jon Ingold

  • Home page
  • Beginning
  • Previous
  • Next



  •     Chapter: Alternative input

        Section: Character input (single keystroke)

    The built-in extension Basic Screen Effects already handles single keystroke input (also known as "char input" or "character input"), but it can do so only in the main window. Even in a multiple window layout, this if often sufficient, since in nearly all games the main window will always be open, and thus always available for input. However, there may be some situations in which we want to accept character input in other windows, such as when another window has been opened "in front" of the main-window for some special purpose. For these situations we offer the following phrases. Note that most of them are simply extensions of the Basic Screen Effects phrases to allow specification of the window:

        wait for any key in the side-window
        wait for the SPACE key in the side-window

        ...the character code entered in the side-window
        
    The latter phrase both checks for a keypress and return a representation of the input as a numerical code. For example, the following would check for a keypress on startup, and print something if the key pressed was the spacebar:

        When play begins:
            if the character code entered in the main-window is 32:
                say "You pressed the space bar. Good work."