PROGRAM KEYLSTNR!       Example keylistener.f

! Code converted using TO_F90 by Alan Miller
! Date: 2001-03-15  Time: 10:03:54

USE JAPI

INTEGER :: frame,obj,keylst
CHARACTER (LEN=60) :: str

CALL j_setdebug(0)

IF( .NOT. j_start()) THEN
  PRINT*, "can't connect to JAPI server"
  GO TO 20
END IF

frame = j_frame("Press a Key in the Window")
CALL j_show(frame)

keylst = j_keylistener(frame)
NEXTACTION: DO
      obj = j_nextaction()

IF(obj == keylst) THEN
 WRITE(unit=str,fmt="(a,i3,a,i3,a,a )") "Keycode:",j_getkeycode(keylst),&
   " Ascii:",j_getkeychar(keylst), " Char:",CHAR(j_getkeychar(keylst))
  
  CALL j_settext(frame,str)
END IF

IF(obj == frame) EXIT NEXTACTION

END DO NEXTACTION

20      CONTINUE
CALL j_quit()

END PROGRAM KEYLSTNR

