keycode

Convert character to virtual key code

守給你的承諾、 提交于 2019-12-19 09:44:59
问题 I have a string of values, and I want to simulate key press events in a window for each character. I plan on sending WM_KEYDOWN, WM_CHAR, and WM_KEYUP events to the window (as that is what seems to happen whan a key is manually pressed). Those messages require an int be sent in the wParam based on a table of virtual key codes. I can loop through the string and get each character, but how do I take that character and convert it to a value that corresponds to the virtual key code? Convert

Double characters shown when typing special characters while logging keystrokes in c#

霸气de小男生 提交于 2019-12-19 04:15:07
问题 I have an application that logs whatever the user press, but when I press special characters like ´ with a , to get á , I get ´´a ; same thing when I want to get à , then i get ``a , so all special characters get typed twice and then the regular character get typed after. I have searched for ever and can't find anything really. But I have noticed that the problem is in the ToAscii method , without that the characters are typed correctly. public string GetString(IntPtr lParam, int vCode) { try

Using event.which to verify if the user pressed the spacebar doesn't work in Firefox

≡放荡痞女 提交于 2019-12-19 03:40:50
问题 I want a script to verify if the key pressed is 'spacebar', keycode 32. I noticed that IE uses other function names. I tried a lot of solutions found here and this: event = event || window.event // IE does not pass event to the function if(event == window.event){ code = event.keyCode; }else{ code = event.which; } if(code == '32') {} But it still didn't work in Firefox. I think I'm calling the function wrongly in Firefox. Look at the entire script: <textarea onkeydown="predicao(this);" cols=

Why jQuery's event.which gives different results in Firefox and Chrome?

梦想的初衷 提交于 2019-12-18 08:22:32
问题 Have a look at this live demo (from jQuery's site). Clicking - (dash) in Firefox says that event.which is 173 , while doing the same in Chrome produces 189 . This jQuery page says that event.which should be normalized for cross browser consistency. But, it looks like this is not true. Why is this inconsistency? 回答1: This jQuery page says that event.which should be normalized for cross browser consistency. But, it looks like this is not true. jQuery normalizes the property name (e.g., always

Get unicode value of character

不问归期 提交于 2019-12-18 07:12:22
问题 Is there any way to get the keycode of a char? For example getKeycode('C'); Is there anything like that? Thanks 回答1: char ch='c'; int code = ch; System.out.println(code); OUTPUT: 99 just for escape char \ you have to use like char ch='\\'; 回答2: A way is this: char c = 'f'; System.out.println("code="+(int)c); I mean, you should make a casting form char to int ; 回答3: public static int KeyEvent.getExtendedKeyCodeForChar( int key ); This will return an extended key code for the unicode character

js disabling backspace functionality in firefox

痴心易碎 提交于 2019-12-17 20:39:37
问题 I have following javascript to prevent user from entering invalid characters into a text field. It's working well in chrome but not in firefox. It's preventing the backspace key to be entered in the text field in firefox. function onlyNumbers(evt) { var theEvent = evt || window.event; var key = theEvent.keyCode || theEvent.which; key = String.fromCharCode( key ); var regex = /[0-9]|\./; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) theEvent.preventDefault(

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

落花浮王杯 提交于 2019-12-17 15:39:26
问题 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. 回答1: Keydown will give you the keyCode of the key pressed, without any modifications.

JQuery allow only two numbers after decimal point

喜夏-厌秋 提交于 2019-12-17 15:25:51
问题 I found the following JQuery function here which prevents a user from entering anything that's not a number or a single decimal. The function works well but I'd like to improve it to prevent the user from entering 3 or more decimal places i.e. disallow 99.999 and allow 99.99. Any ideas? function checkForInvalidCharacters(event, inputBox){ if ((event.which != 46 || inputBox.val().indexOf('.') != -1) && (event.which < 48 || event.which > 57)) { event.preventDefault(); } }; 回答1: The logic is

javascript subtract(-) keycode

你离开我真会死。 提交于 2019-12-17 09:46:30
问题 ok, i need my code to check if minus/subtract/- was pressed, if it was pressed i want an alert box to pop. i tried with both 109 and 189 key codes but i still don't get the desired result. although i press "-" i don't get that alert box 回答1: The JavaScript charCodes , which you test for during a keypress event, are ASCII. 109 is the correct keyCode , if used in a keydown or keyup event. "-" has a charCode of 45. 回答2: 1.event.keyCode = 109 is '-' on numpad 2.event.keyCode = 189 is'-' in

安卓手机键码表

纵饮孤独 提交于 2019-12-16 01:07:29
键英文名 键中文名 键代码 键类型 KEYCODE_CALL 拨号键 5 电话键 KEYCODE_ENDCALL 挂机键 6 KEYCODE_HOME 按键Home 3 KEYCODE_MENU 菜单键 82 KEYCODE_BACK 返回键 4 KEYCODE_SEARCH 搜索键 84 KEYCODE_CAMERA 拍照键 27 KEYCODE_FOCUS 拍照对焦键 80 KEYCODE_POWER 电源键 26 KEYCODE_NOTIFICATION 通知键 83 KEYCODE_MUTE 话筒静音键 91 KEYCODE_VOLUME_MUTE 扬声器静音键 164 KEYCODE_VOLUME_UP 音量增加键 24 KEYCODE_VOLUME_DOWN 音量减小键 25 KEYCODE_ENTER 回车键 66 控制键 KEYCODE_ESCAPE ESC键 111 KEYCODE_DPAD_CENTER 导航键 确定键 23 KEYCODE_DPAD_UP 导航键 向上 19 KEYCODE_DPAD_DOWN 导航键 向下 20 KEYCODE_DPAD_LEFT 导航键 向左 21 KEYCODE_DPAD_RIGHT 导航键 向右 22 KEYCODE_MOVE_HOME 光标移动到开始键 122 KEYCODE_MOVE_END 光标移动到末尾键 123