Disable default behaviour for the key strokes that listbox responds in zk(Ex:up and down)

asked 2015-07-12 08:42:34 +0800

Rao gravatar image Rao
3 2

Lisbox in zk by default answers keystrokes like page up and page down, up and down keys and home and end keys. Ex: I want the currently selected row to come down when user hits down arrow. I gave all above keys in ctrlKeys attribute, to call the backend bean when specific keys are hit. But it doesn't call for above keys. It calls back end bean for keys like "delete". I want to disable the default behaviour for above keys for listbox in zk. Kindly help me. This is the ctrlKeys attribute I gave, ctrlKeys="#home#end#del#up#down#pgup#pgdn" onCtrlKey="@command('answerKeyStroke',keyCode=event.getKeyCode(), id=0)"

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted

answered 2015-07-12 13:54:48 +0800

Darksu gravatar image Darksu
1991 1 4

Hello Rao,

You can use the following example in order to capture the key event, and then you can add your own logic:

<?page title="Auto Generated index.zul"?>
<window title="Hello World!!" border="normal" width="200px">

<label value="You are using: ${desktop.webApp.version}"/>

<zk xmlns:w="client">

    <listbox >
     <attribute w:name="_doKeyDown"><![CDATA[

            function (evt) {

                var keyCode = evt.keyCode;
                if (keyCode != 38 && keyCode != 40) {

        <listheader label="col 1" sort="auto" />
        <listheader label="col 2" sort="auto" />
        <listcell label="1.1" />
        <listcell label="1.2" />
        <listcell label="2.1" />
        <listcell label="2.2" />


Best Regards,


link publish delete flag offensive edit

answered 2015-07-16 05:21:11 +0800

Rao gravatar image Rao
3 2

Hey Darksu,

That worked like a charm.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2015-07-12 08:42:34 +0800

Seen: 16 times

Last updated: Jul 16 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More