0

Grabbing ctrl+numpad keys on window.

asked 2016-12-15 12:47:52 +0800

delpan gravatar image delpan
1

How can i write a logic when user presses ctrl+numpad1 while staying on the window.Currently numpad keys are not listed in ctrlkeys list.I managed to grab the keys on a textbox and zk.Widget.fire the onCtrlKey event and it works as if i have pressed any of the listed keys.But it only works on a textbox that i have overriden the afterKeyDown_ attribute only.I want to be able to grab the numpad keys wherever the user is on that window.

<attribute w:name="afterKeyDown_"><![CDATA[
            function (evt/*, simulated*/) {
                this.$afterKeyDown_(evt);
                var keyCode = evt.keyCode,
                    target = wgt = this;
    zk.log(keyCode);
                if ( evt.domTarget == this.getInputNode()
                    && evt.ctrlKey
                    && (keyCode == 97 ) ) {
                    var wgt = this;
                    zk.log('here');
                    zk.Widget.$('$win').fire('onCtrlKey',{'keyCode':keyCode}, {toServer:true});
                }
            }
        ]]></attribute>
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-12-29 11:14:28 +0800

delpan gravatar image delpan
1

This was the way by which i could manage to listen on the ctrlkeys+numpad keys and fire the same corresponding event to the server ,whereas on server i have a listener for the event fired.

<script defer="true">
    zk.Widget.$('$win').$n().onkeydown = function(e) 
    {
        e = e || window.event;

        if(e.ctrlKey)
        {
        var charCode =  e.keyCode;
            if (charCode==97 || charCode==105 || charCode==103)//ctrl+numpad1 || ctrl+numpad9 || ctrl+numpad7 
            {

                zk.Widget.$('$win').fire('onCtrlKey',{keyCode:charCode}, {toServer:true});
            }
            else if(charCode==100)//ctrl+numpad4
            {
                acccb('mdata');
            }
        }
        else if(e.altKey)
        {
            var charCode =  e.keyCode;

        }
    };



   </script>
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

Follow
1 follower

RSS

Stats

Asked: 2016-12-15 12:47:52 +0800

Seen: 45 times

Last updated: Dec 29 '16

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