Function LastKey() Foundation

Retrieves the Inkey() value of last key pressed.

Syntax
LastKey() --> nInkeyCode
Return

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.

Description

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 "Inkey.ch" 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.

Examples
LastKey()
// In the example the key used to end a READ 
// is retrieved. 

#include "Inkey.ch" 

PROCEDURE Main 
   LOCAL cName 
   USE Address NEW 

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

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

Feedback

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.