INKEY$ and
characterInput

Just BASIC has a special variable named Inkey$ which can be used to fetch keys pressed.  This only works with the graphicbox and with windows opened for graphics.  Graphics controls handle an event called characterInput, which copies pressed-key codes into the Inkey$ variable.  See Graphics Commands, Inkey$ , Reading Mouse Events and Keystrokes, and Using Virtual Key Contants with Inkey$ for more details.