Processing...
Description & Source Code

Keystroke events are supported for the ENTER, ESC, and CTRL keys, which are handled by onOK, onCancel, and onCtrlKey respectively. The function keys are treated as CTRL keys.

keystroke_event.zul
<zk>
	<grid width="400px">
		<rows>
			<row>
				Password
				<textbox id="inp" ctrlKeys="^a#f8" type="password" value="123456789" width="150px">
					<attribute name="onOK"><![CDATA[
						Messagebox.show("ENTER key is pressed", "OK", 
								Messagebox.OK, Messagebox.EXCLAMATION);
						self.focus();
					]]></attribute>
					<attribute name="onCancel"><![CDATA[
						Messagebox.show("ESC key is pressed", "CANCEL", 
								Messagebox.OK, Messagebox.EXCLAMATION);
						self.focus();
					]]></attribute>
					<attribute name="onCtrlKey"><![CDATA[
						int keyCode = ((KeyEvent) event).getKeyCode();
						String s = "";
						switch(keyCode){
							case 65: s = "Ctrl+A";break;
							case 119: s = "F8";break;
						}
						Messagebox.show(s+" is pressed", "CtrlKey", 
								Messagebox.OK, Messagebox.EXCLAMATION);
						inp.focus();
					]]></attribute>
				</textbox>
			</row>
		</rows>
	</grid>
	<zscript><![CDATA[
		inp.focus();
	]]></zscript>
</zk>