开发者

jQuery arrow key binding ( webbrowser class IE )

开发者 https://www.devze.com 2023-02-16 11:52 出处:网络
I have an application which uses the microsoft webbrowser class ( IE activex ). I\'m trying to bind the keydown event and add custom control to the arrow keys, but the keydown event is not fired when

I have an application which uses the microsoft webbrowser class ( IE activex ). I'm trying to bind the keydown event and add custom control to the arrow keys, but the keydown event is not fired when using the arrow keys.

I tried following code to capture the keydown event:

$(document).keydown(function(e){   
alert("keydown");  });

$("#element").keydown(function(e){   
alert("keydown");  });

document.onkeydown = function(evt) {
  evt = evt || window.event;
  var keyCode = evt.keyCodeq
  if (keyCode >= 37 && keyCode <= 40) {
      alert("ok");
      return false;
  }
};

The keydown event works, delete key by example, but not when using the 开发者_StackOverflowarrow keys. When I use the arrow keys in the activex browser, the document scrolls, but it's not possible to add custom control.

In regular IE (non activex) everything works fine.

Any suggestions?


Actually there is nothing to do much.

1.

<input type="text" id="test_element">

2.

<script type="text/javascript">
$(function(){
 $("#test_element").keydown(function(e){
  switch(e.which){
   case 37: movement = 'left'; break;
   case 38: movement = 'up'; break;
   case 39: movement = 'down'; break;
   case 40: movement = 'right'; break;
   default: movement = false; break;
  }
  if(movement){
    alert("You just clicked "+movement+" arrow key");
  }
 });
});
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号