Functions and Directives

Function LastKey() Foundation

Retrieves the Inkey() value of last key pressed.

LastKey() --> nInkeyCode

The return value of LastKey() is an integer in the range of -47 to 422. This value is the Inkey() code of the last keypress read from the keyboard buffer.


The function LastKey() is a compatibility function which returns the last value retrieved from the keyboard buffer using Inkey(). In the Xbase++ system the function LastAppEvent(), which returns mouse events as well as keyboard events, should be used instead of LastKey().

LastKey() stores the last value read from the keyboard buffer until the next value is taken from the keyboard buffer. Using LastKey() the last key pressed can be determined in the user functions of AChoice(), DbEdit(), MemoEdit() and the default dialog elements. Also the last user input can be checked after the commands ACCEPT, INPUT, READ and WAIT.

The functions Inkey(), LastKey() and NextKey() are used for retrieving keyboard input. Inkey() reads the next keypress and removes it from the keyboard buffer. NextKey() reads the next keypress without removing it from the keyboard buffer. LastKey() returns the last keypress removed from the keyboard buffer.

Symbolic constants are defined in the header file "" for all key codes returned from LastKey().

LastKey() is a compatibility function used with the Get system and functions such as AChoice(). Such functions require a console window and hence can only be used in text and hybrid mode applications.

// In the example the key used to end a READ 
// is retrieved. 

#include "" 

   LOCAL cName 
   USE Address NEW 

   cName := Addresses->Name 
   @ 10, 10 SAY "Customer:" GET cName 

   IF Updated() .AND. (LastKey() <> K_ESC) 
      REPLACE Addresses->Name WITH cName 


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.