Event Name |
Components |
Description |
---|---|---|
onOK |
window |
Event: org.zkoss.zk.ui.event.KeyEvent Denotes user has pressed the ENTER key. |
onCancel |
window |
Event: org.zkoss.zk.ui.event.KeyEvent Denotes user has pressed the ESC key. |
onCtrlKey |
window |
Event: org.zkoss.zk.ui.event.KeyEvent Denotes user has pressed a special key, such as PgUp, Home and a key combined with the Ctrl or Alt key. Refer to the ctrlKeys Property section below for details. |
The keystroke events are sent to the nearest window that has registered an event listener for the specified events. It is designed to implement the submit, cancel and shortcut functions.
As illustrated below, doA() is invoked if user pressed ENTER when T1 got the focus, and doB() is invoked if user pressed ENTER when T2 got the focus.
<window id="A" onOK="doA()"> <window id="B" onOK="doB()"> <textbox id="T1"/> </window> <textbox id="T2"/> </window
Notice that a window doesn't receive the keystroke events that are sent for the inner window, unless you post them manually. In the above example, the event won't be sent to window A, if T1 got the focus, no matter whether the onOK handler is declared for window B or not.
To receive the onCtrlKey event, you must specify what key strokes to intercept by the ctrlKeys property. In other words, only key strokes specified in the ctrlKeys property is sent back to the server. For example, the onCtrlKey event is sent if a user clicks Alt+C, Ctrl+A, F10, or Ctrl+F3.
<window ctrlKeys="@c^a#10^#3"> ...
The following is the syntax of th ctrlKeys property.