我可以使用JavaScript启用/禁用客户端数字锁定吗? [英] Can I enable/disable client num-lock using JavaScript?

查看:115
本文介绍了我可以使用JavaScript启用/禁用客户端数字锁定吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发c#Web应用程序,我想让用户使用num-lock作为在我的应用程序上切换某些选项的快捷键,但不希望它禁用数字键盘.

I'm developing c# web application and I want to let user use num-lock as a short key for switch some options on my app but don't want it to disable the num-pad.

我可以使用JavaScript实现吗?

Can I achieve this using JavaScript?

我想做的是当用户按下键(然后指示灯熄灭)但用户仍然可以通过数字键输入字段

EDIT : What I want to do is when user press the key (then the light turn off) but user still can key number to input field

例如按数字锁定"购买/按-"出售,然后输入价格

Ex. press 'Num-lock' to buy / press '-' to sell then enter the price

推荐答案

这是我正在寻找的最接近的 jsFiddle

Here is the closest to what I'm looking for jsFiddle

 $('#textbox').keydown(function(event){
    var keycode = (event.keyCode ? event.keyCode : event.which);
    $('#keydownCode').html(keycode);


 if(keycode == 144){
    $('#Typoef').html('It is a Sell');
     //perform Sell operation here
 }
 else if(keycode == 109){
    $('#Typoef').html('It is a Purchase');
     //perform Purchase operation here
 }
 else if(keycode == 35){
    $('#textbox').val($('#textbox').val()+"1");
     e.preventDefault();
 }
 else if(keycode == 40){
    $('#textbox').val($('#textbox').val()+"2");
     e.preventDefault();
 }
 else if(keycode == 34){
    $('#textbox').val($('#textbox').val()+"3");
     e.preventDefault();     
 }
 else if(keycode == 37){
     $('#textbox').val($('#textbox').val()+"4");
     e.preventDefault(); 
 }
 else if(keycode == 12){
    $('#textbox').val($('#textbox').val()+"5");
     e.preventDefault();     
 }
 else if(keycode == 39){
    $('#textbox').val($('#textbox').val()+"6");
     e.preventDefault();     
 }
 else if(keycode == 36){
    $('#textbox').val($('#textbox').val()+"7");
     e.preventDefault();     
 }
 else if(keycode == 38){
    $('#textbox').val($('#textbox').val()+"8");
     e.preventDefault();     
 }else if(keycode == 33){
    $('#textbox').val($('#textbox').val()+"9");
     e.preventDefault();     
 }
 else if(keycode == 45){
    $('#textbox').val($('#textbox').val()+"0");
     e.preventDefault();     
 }
 else{
     $('#Typoef').html('');
 }
});

这篇关于我可以使用JavaScript启用/禁用客户端数字锁定吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆