-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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>
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>
Asked: 2016-12-15 12:47:52 +0800
Seen: 47 times
Last updated: Dec 29 '16