; Built-in constants (an ArcBasic extension) ; Named keys and mouse buttons light up while you hold them. ; Hold any of the keys shown, click the mouse buttons. Escape quits. Graphics 800, 500 SetBuffer BackBuffer() AppTitle "Built-in constants" ; every key on the board: its label, where it goes and its constant Type Pad Field label$, code Field x, y, w End Type Restore keys Repeat Read label$ If label$ = "" Then Exit p.Pad = New Pad p\label = label$ Read p\code, p\x, p\y, p\w Until False .keys Data "Esc", KEY_ESCAPE, 40, 60, 60 Data "F1", KEY_F1, 130, 60, 50, "F2", KEY_F2, 185, 60, 50, "F3", KEY_F3, 240, 60, 50, "F4", KEY_F4, 295, 60, 50 Data "Tab", KEY_TAB, 40, 130, 70 Data "Q", KEY_Q, 115, 130, 45, "W", KEY_W, 165, 130, 45, "E", KEY_E, 215, 130, 45, "R", KEY_R, 265, 130, 45 Data "A", KEY_A, 130, 180, 45, "S", KEY_S, 180, 180, 45, "D", KEY_D, 230, 180, 45 Data "Shift", KEY_LSHIFT, 40, 230, 90, "Z", KEY_Z, 135, 230, 45, "X", KEY_X, 185, 230, 45, "C", KEY_C, 235, 230, 45 Data "Ctrl", KEY_LCTRL, 40, 280, 70, "Alt", KEY_LALT, 115, 280, 60, "Space", KEY_SPACE, 180, 280, 230 Data "Enter", KEY_ENTER, 330, 180, 80 Data "Up", KEY_UP, 560, 230, 50, "Left", KEY_LEFT, 505, 280, 50, "Down", KEY_DOWN, 560, 280, 50, "Right", KEY_RIGHT, 615, 280, 50 Data "Home", KEY_HOME, 505, 130, 50, "End", KEY_END, 505, 180, 50, "PgUp", KEY_PAGEUP, 615, 130, 50, "PgDn", KEY_PAGEDOWN, 615, 180, 50 Data "" While Not KeyHit(KEY_ESCAPE) Cls Color 255, 255, 255 Text 400, 16, "Hold the keys shown, and click the mouse. Escape quits.", True ; keys: lit while held, using the constant each one was given For p.Pad = Each Pad If KeyDown(p\code) Then Color 255, 120, 220 Else Color 50, 60, 90 Rect p\x, p\y, p\w, 40 Color 255, 255, 255 Text p\x + p\w / 2, p\y + 20, p\label, True, True Next ; the mouse, with its three buttons DrawButton(560, 360, "Left", MOUSE_LEFT) DrawButton(620, 360, "Middle", MOUSE_MIDDLE) DrawButton(680, 360, "Right", MOUSE_RIGHT) Color 80, 90, 120 Rect 560, 400, 180, 60 Color 170, 180, 210 Text 40, 380, "KeyDown(KEY_LEFT) means the same as KeyDown(203)," Text 40, 400, "and MouseDown(MOUSE_RIGHT) the same as MouseDown(2)." Text 40, 430, "See them all: Help > Commands > Built-in constants." Flip Wend End Function DrawButton(x, y, label$, button) If MouseDown(button) Then Color 255, 120, 220 Else Color 50, 60, 90 Rect x, y, 58, 38 Color 255, 255, 255 Text x + 29, y + 19, label$, True, True End Function