keycode

Can javascript tell the difference between left and right shift key?

不羁的心 提交于 2019-11-27 08:51:58
Mostly this is a sanity check. The key code for both shift keys is 16. Does that mean it is actually impossible to distinguish a left and right shift events in a browser? In newer browsers supporting DOM3 you can use event.location to check the location. In the DOM3 spec , there are 4 constants defined for location, DOM_KEY_LOCATION_STANDARD , DOM_KEY_LOCATION_LEFT , DOM_KEY_LOCATION_RIGHT , and DOM_KEY_LOCATION_NUMPAD . In this case, you can do: if (event.location === KeyboardEvent.DOM_KEY_LOCATION_LEFT){ } else if (event.location === KeyboardEvent.DOM_KEY_LOCATION_RIGHT){ } MattG Internet

How can I convert a key code into a char or string?

戏子无情 提交于 2019-11-27 07:35:48
问题 How to convert the keycode into char or string ?? Here is the example code: public boolean onKey(View v, int keyCode, KeyEvent event) { // TODO Auto-generated method stub //Log.d("EditText", "It's Working...!" + event.getAction()); if (event.getAction() == 0) { switch (v.getId()) { case R.id.editText1: Log.d("EditText", "In editText1"); if (text1.length() == 3) { text2.setText(); text2.requestFocus(); } break; case R.id.editText2: Log.d("EditText", "In editText2"); if (text2.length() == 0)

Determine if JavaScript e.keyCode is a printable (non-control) character

耗尽温柔 提交于 2019-11-27 07:32:43
I'd just like to know the range(s) of JavaScript keyCode s that correspond to typeable characters; or alternatively, the range of non-typeable (control) characters like backspace, escape, command, shift, etc. so I can ignore them. The reason I ask is calling String.fromCharCode() is resulting in odd characters for control keys. For example I get "[" for left command, "%" for left arrow. Weirdness like that. Keydown will give you the keyCode of the key pressed, without any modifications. $("#keypresser").keydown(function(e){ var keycode = e.keyCode; var valid = (keycode > 47 && keycode < 58) ||

How to obtain the keycodes in Python

霸气de小男生 提交于 2019-11-27 04:31:30
问题 I have to know what key is pressed, but not need the code of the Character, i want to know when someone press the 'A' key even if the key obtained is 'a' or 'A', and so with all other keys. I can't use PyGame or any other library (including Tkinter). Only Python Standard Library. And this have to be done in a terminal, not a graphical interface. NOT NEED THE CHARACTER CODE. I NEED TO KNOW THE KEY CODE. Ex: ord('a') != ord('A') # 97 != 65 someFunction('a') == someFunction('A') # a_code == A

js限制input输入

强颜欢笑 提交于 2019-11-27 03:36:19
1.取消按钮按下时的虚线框,在input里添加属性值 hideFocus 或者 HideFocus=true <input type="submit" value="提交" hidefocus="true" /> 2.只读文本框内容,在input里添加属性值 readonly <input type="text" readonly /> 3.防止退后清空的TEXT文档(可把style内容做做为类引用) <input type="text" style="behavior:url(#default#savehistory);" /> 4.ENTER键可以让光标移到下一个输入框 <input type="text" onkeydown="if(event.keyCode==13)event.keyCode=9" /> 5.只能为中文(有闪动) <input type="text" onkeyup="value=value.replace(/[ -~]/g,'')" onkeydown="if(event.keyCode==13)event.keyCode=9" /> 6.只能为数字(有闪动) <input type="text" onkeyup="value=value.replace(/[^\d]/g,'') " onbeforepaste="clipboardData

js限制input输入

时光怂恿深爱的人放手 提交于 2019-11-27 03:35:53
1.取消按钮按下时的虚线框,在input里添加属性值 hideFocus 或者 HideFocus=true <input type="submit" value="提交" hidefocus="true" /> 2.只读文本框内容,在input里添加属性值 readonly <input type="text" readonly /> 3.防止退后清空的TEXT文档(可把style内容做做为类引用) <input type="text" style="behavior:url(#default#savehistory);" /> 4.ENTER键可以让光标移到下一个输入框 <input type="text" onkeydown="if(event.keyCode==13)event.keyCode=9" /> 5.只能为中文(有闪动) <input type="text" onkeyup="value=value.replace(/[ -~]/g,'')" onkeydown="if(event.keyCode==13)event.keyCode=9" /> 6.只能为数字(有闪动) <input type="text" onkeyup="value=value.replace(/[^\d]/g,'') " onbeforepaste="clipboardData

js限制input输入

隐身守侯 提交于 2019-11-27 03:34:26
跟大家分享一些关于限制input输入的知识点,欢迎指正! 1.取消按钮按下时的虚线框,在input里添加属性值 hideFocus 或者 HideFocus=true hideFocus即隐藏聚焦,具有使对象聚焦失效的功能,其功能相当于: onFocus="this.blur()" 它的值是一个布尔值,如hideFocus=“true”,也可省略赋值直接写hideFocus。 <input type="submit" value="提交" hidefocus="true" /> 2.只读文本框内容,在input里添加属性值 readonly <input type="text" readonly /> 3.防止退后清空的TEXT文档(可把style内容做为类引用) <input type="text" style="behavior:url(#default#savehistory);" /> 4.ENTER键可以让光标移到下一个输入框 <input type="text" onkeydown="if(event.keyCode==13)event.keyCode=9" /> 5.只能为中文(有闪动) <input type="text" onkeyup="value=value.replace(/[ -~]/g,'')" onkeydown="if(event.keyCode=

js限制input输入

試著忘記壹切 提交于 2019-11-27 03:34:02
1.取消按钮按下时的虚线框,在input里添加属性值 hideFocus 或者 HideFocus=true <input type="submit" value="提交" hidefocus="true" /> 2.只读文本框内容,在input里添加属性值 readonly <input type="text" readonly /> 3.防止退后清空的TEXT文档(可把style内容做做为类引用) <input type="text" style="behavior:url(#default#savehistory);" /> 4.ENTER键可以让光标移到下一个输入框 <input type="text" onkeydown="if(event.keyCode==13)event.keyCode=9" /> 5.只能为中文(有闪动) <input type="text" onkeyup="value=value.replace(/[ -~]/g,'')" onkeydown="if(event.keyCode==13)event.keyCode=9" /> 6.只能为数字(有闪动) <input type="text" onkeyup="value=value.replace(/[^\d]/g,'') " onbeforepaste="clipboardData

event.keyCode not working in Firefox

妖精的绣舞 提交于 2019-11-27 03:31:53
问题 I'm having a problem with a Login page I'm developing on ASP.net C#. The form works on IE, but not Firefox. Here's my sample: <%@ Page Language="c#" Inherits="ClubCard.loginClubcard" CodeFile="loginClubcard.aspx.cs" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <html> <head> <title> Acceso Clubcard </title> <meta http-equiv="Page-Enter" content="blendTrans(Duration=0.25)" /> <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.25)" /> <link rel="stylesheet" type=

How to know if .keyup() is a character key (jQuery)

只谈情不闲聊 提交于 2019-11-27 03:02:43
How to know if .keyup() is a character key (jQuery) $("input").keyup(function() { if (key is a character) { //such as a b A b c 5 3 2 $ # ^ ! ^ * # ...etc not enter key or shift or Esc or space ...etc /* Do stuff */ } }); Nivas Note: In hindsight this was a quick and dirty answer, and may not work in all situations. To have a reliable solution, see Tim Down's answer (copy pasting that here as this answer is still getting views and upvotes): You can't do this reliably with the keyup event. If you want to know something about the character that was typed, you have to use the keypress event