Parameter | Description |
---|---|
bPrintable | Indicates if the key can result in a printable character. |
sKey | String representing the key being pressed. |
Procedure OnKey Boolean bPrintable String sKey
Event hook that is called for each key press in the form.
It is based on the keydown DOM event. Multiple events within a few milliseconds will be bundled into a single server roundtrip.
The key does not have to make a change to the form (function keys) and some browsers will not provide a proper key string.
Not every change to the value triggers an OnKey event, to perform an operation every value change, use the OnInput event.
See https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values for a list of possible values for sKey. Unfortunately, some browsers do not specify a proper value and will pass "Unidentified".
Note that this event is turned off by default (pbServerOnKey).
The example below shows how to implement the OnKey event and show the output inside a cWebHtmlBox:
Object oForm is a cWebForm Set piColumnSpan to 0 Set psLabel to "Type here:" Set pbServerOnKey to True Procedure OnKey Boolean bPrintable String sKey Send PrependHtml of oDebugKeys (SFormat("OnKey (bPrintable: <b>%1</b>, sKey: <b>'%2'</b>)<br>", bPrintable, sKey)) End_Procedure End_Object Object oDebugKeys is a cWebHtmlBox Set piColumnSpan to 0 Set psHtml to "" Set pbFillHeight to True Set pbScroll to True End_Object