Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - lastkey() return last key removed from keyboard buffer http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 lastkey()           Return last key removed from keyboard buffer
------------------------------------------------------------------------------
 Declaration
   io.hdr

 Syntax
   func uint lastkey extern

 Arguments
   None.

 Return
   The code of the last key in the keyboard buffer.

 Description
   The lastkey() function returns the last key that was removed from the
   keyboard buffer.

 Example
   #define EXAMPLE_IO
   #include example.hdr

   /*
   get allows the use of a keyboard filter. Use lastkey() to retrieve the
   key in your get keyboard filter routine. This function provides an
   "upper" function. This is identical to get "@!"
   */
   
   func int UpperFilter
   vardef
      uint uKey
   enddef
   uKey := lastkey()
   if uKey >= 'a' .and. uKey <= 'z'
      uKey := uKey - 'a' + 'A'        // convert to upper case
   endif
   return( uKey )
   endproc
   
   proc Test_lastkey
   vardef
      char( 20 ) cName
   enddef
   cName := space( 20 )
   clear
   // issue a get that uses the above keyboard filter function, UpperFilter()
   @ 0,0 say "Using filter" get cName filter UpperFilter()
   read
   endproc

   proc main
   Test_lastkey()
   endproc

See Also: __last_key getkey() inkey() iskey()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson