Edit Box - KeyPress Event

Fired when a key is pressed on the keyboard

Member of Edit Box (PRIM_EDIT)

Parameters

NameTypeData TypeDescription
KeyCode*InputEnumerationThe key that was pressed
Char*BothUnicode StringCharacter that was pressed
IsAltDown*InputBooleanIs the Alt key down?
IsControlDown*InputBooleanIs the Ctrl key down?
IsShiftDown*InputBooleanIs the Shift key down?
Handled*BothBooleanSet to true to stop the key being processed automatically

Details

The KeyPress event is fired when a key is pressed.
 
If the key pressed was a character, the Char parameter will contain the character and the KeyCode parameter will contain the value "IsChar".
 
If the key pressed was one of a number of control keys such as arrows, function keys, Home or End, etc., the KeyCode will contain the name of the key, and Char will be empty. Autocomplete or F2 will provide a complete list of available values.
 
Mainstream actions requiring key processing are handled automatically in LANSA.
 
For Enter key processing use the Enter event or a button with a ButtonDefault property of True
 
To hide input for passwords you can use an Edit control with and specify the PasswordChar, or use a field with an input attribute of ND.
 
To interrupt entry to complete a value use the AutoCompleting event on a field.
 
KeyPress is provided for completeness and is unlikely to be required for most development purposes.

Example

This example shows the values output by a KeyPress event.
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Height(469) Left(190) Top(223) Width(686) Clientwidth(670) Clientheight(430) Layoutmanager(#TableLayout1)
 
   Define_Com Class(#PRIM_TBLO) Name(#TableLayout1)
   Define_Com Class(#PRIM_TBLO.Column) Name(#Column1) Displayposition(1) Parent(#TableLayout1)
   Define_Com Class(#PRIM_TBLO.Row) Name(#Row1) Displayposition(1) Parent(#TableLayout1)
   Define_Com Class(#PRIM_TBLO.Item) Name(#ListViewItem1) Column(#Column1) Manage(#ListView) Parent(#TableLayout1) Row(#Row1)
 
   Define_Com Class(#PRIM_LTVW) Name(#ListView) Columnbuttonheight(19) Componentversion(2) Displayposition(1) Fullrowselect(True) Keyboardpositioning(SortColumn) Left(0) Parent(#COM_OWNER) Showsortarrow(True) Tabposition(1) Top(0) Height(430) Width(670)
   Define_Com Class(#PRIM_LVCL) Name(#LVCL1) Displayposition(1) Parent(#ListView) Source(#xDemoAlpha128) Width(33) Captiontype(Caption) Caption('KeyCode')
   Define_Com Class(#PRIM_LVCL) Name(#LVCL2) Displayposition(2) Parent(#ListView) Source(#xDemoCaption) Captiontype(Caption) Caption('Character') Width(26)
 
   Evtroutine Handling(#ListView.KeyPress) Keycode(#KeyCode) Char(#Char)
 
      #xDemoAlpha128 := #KeyCode
      #xDemoCaption := #Char
 
      Add_Entry To_List(#ListView)
 
   Endroutine
 
End_Com
 

See also

All Component Classes

Technical Reference

Febuary 18 V14SP2