;***********************************************************************
;*                                                                     *
;* KEYS.ASP  by Chuck Spohr  (C) 1991 DATASTORM TECHNOLOGIES, INC.     *
;*                                                                     *
;* An ASPECT routine designed to filter the ESC key and prevent        *
;* exiting of a script.  May be modified to filter other PCPLUS        *
;* key sequences                                                       *
;*                                                                     *
;***********************************************************************

integer KeyPress

proc main

   set keys on                   ;* Process all keystrokes from within script
   kflush                        ;* Flush keyboard buffer

                                 ;* Insert Login sequence here

                                 ;* Ready to process all keystrokes:
   while forever                 ;* Infinite loop - could use "while connected"
      if hitkey                  ;* Has a key been hit?
         keyget KeyPress         ;* Get the key
         switch KeyPress         ;* Branch according to key code
            case 0x001B          ;* ESC key
               transmit "^["     ;* Transmit ESC character to host
            endcase

;           case 0x0000          ;* Filter other keystrokes with this type
;              transmit ""       ;* of construct.  Delete the "transmit" if
;           endcase              ;* no character is to be sent.

            default              ;* Any other key
               termkey KeyPress  ;* Type that key as if it were from keyboard
            endcase
         endswitch
      endif
   endwhile

endproc
