开发者

How to detect CTRL+V in javascript with Cyrillic layout?

I detect ctrl+v in keydown event in such a way:

.keydown(function(e){
   if ( e.ctrlKey && e.keyCode == 86 ) {
      console.log ('ctrl+v!');
   }
});

it works fine, when my layout is latin (English). But when I switch my layout to Russian (cyrillic) - ctrl+v is executed (text is inserted) but jQuery detection doesn't work. (e.keyCode = 0 of cyrillic symbols).

P.S. I need it in good order (for preformatting inserted text )

P.P.S. My task was accomplished w开发者_JS百科ithout detection of pasting. (just listening on keyup event was enough for me), but the problem exist on my PC (Ubuntu, Fx6). keyCode of Cyrillic symbols is recognized as 0, and you can't detect shortcuts with latin letters (ctrl+c,ctrl+v, etc).


This works fo me on ubuntu too(FF 5):

.keypress(function(e){
    if ( e.ctrlKey && (e.which == 86 || e.which==118) ) {
      console.log ('ctrl+v!');
   }
});

for ctrl+n use

 if ( e.ctrlKey && (e.which == 110 || e.which==78) ) 

and for ctrl+t:

if ( e.ctrlKey && (e.which == 84 || e.which==116) )
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜