Waiting for key presses

Function

Suspend the user application program, waiting for a key press.

Syntax

Detailed Description

This particular WAIT statement waits for port 0 bit 0 to go to 1, indicating that there is data in the keyboard buffer.

To wait until ENT, F1, or other specific key is pressed, use this WAIT statement to wait for a key press, read the key data with the INKEY$ function, and thus determine which key was pressed.

The following table gives the default key assignments.

Key Default key data
F1 A
F2 B
F3 C
F4 D
F5 E
F6 F
F7 G
F8 H
ENT Carriage return (0Dh)
BS Backspace (08h)
C Cancel (18h)
For further details on keys other than the above, refer to Appendix E "Key Number Assignment on the Keyboard" in the BHT-BASIC Programmer's Manual.

Examples

Wait until ENT key pressed
  private waitENT$
waitENT:
  wait 0,&h01                    ' wait for key press
  waitENT$ = inkey$              ' read key data for key pressed
  if waitENT$ <> chr$(&h0D) then ' if key not ENT
    goto waitENT                 ' wait for next key press
  endif
  print "ENT"
Wait until F1 or F2 key pressed
  private waitkey$
waitkey:
  wait 0,&h01                    ' wait for key press
  waitkey$ = inkey$              ' read key data for key pressed
  select waitkey$
    case "A":                    ' if F1 key
      print "F1"                 ' display key name
    case "B":                    ' if F2 key
      print "F2"                 ' display key name
    case else:                   ' if key not F1 or F2
      goto waitkey               ' wait for next key press
  end select

(C)2002-2004 DENSO WAVE INCORPORATED All right reserved