keycode

How do you determine if a character requires the shift key to be down to be typed?

佐手、 提交于 2019-12-10 18:48:24
问题 I am writing some code to type strings using the Robot class. Everything is mostly good (well, I have to use a big switch statement to get character keycodes), except some keys don't have keycodes, because they are actually a combination of Shift + some other key. For upper case letters, it is easy to check, using Character.isUpperCase(c) , but for all the symbols such as !@#$%^&*()_+ and various punctuation are not considered "upper case" although they do require shift to be pressed in order

String.fromCharCode on keypress and keydown are returning wrong characters

泪湿孤枕 提交于 2019-12-10 17:35:13
问题 I'm trying to catch the character inserted before it shows on the screen to validate the screen. See my code _this.on('keypress keydown',function(e){ var t = e.target; var k = e.which || e.keyCode; var c = String.fromCharCode(k); console.log(String.fromCharCode(k)) }); If I for example type ~ or any other punctuation characters, it returns non-latin characters, such as å . I'm on Chromium, Ubuntu. I noticed that the keypress is being ignored with these special characters, what is a shame and

Insert four spaces instead of tab

落爺英雄遲暮 提交于 2019-12-10 14:49:27
问题 I am trying to insert four spaces when the tab key is pressed. I was using the following code (see spaces = "\t" ), but when I switch it to spaces = " " only one space is inserted when I press tab. I also tried " " + " " + " " + " ": $(function () { $('textarea').keydown(function(e) { var keyCode = e.keyCode || e.which; if (keyCode == 9) { e.preventDefault(); var start = $(this).get(0).selectionStart; var end = $(this).get(0).selectionEnd; // set textarea value to: text before caret + tab +

KeyEventArgs.KeyData, KeyEventArgs.KeyCode and KeyEventArgs.KeyValue

倾然丶 夕夏残阳落幕 提交于 2019-12-09 04:50:21
问题 I have question about the KeyEventArgs 's KeyCode and KeyData and KeyValue . KeyCode and Keydata are Keys type, but I don't know what the difference between them is. For KeyValue , I don't know what it is -- it has an int type, does it return the char value of the pressed key? I don't have much experience with Key events; any explanation of how they function and how to use them would be greatly appreciated. 回答1: KeyCode contains data for the key that produced the KeyUp or KeyDown event.

KeyDown recognizes the left and right directional arrow keys, but not up and down

拟墨画扇 提交于 2019-12-08 21:53:29
问题 With the code below, the Left and Right arrow keys function as expected, but the up and down arrows are not recognized (stepping through it, the first two conditions are met where appropriate, but the second two never are): private void textBox1_KeyDown(object sender, KeyEventArgs e) { TextBox tb = (TextBox)sender; if (e.KeyCode.Equals(Keys.Left)) { SetFocusOneColumnBack(tb.Name); e.Handled = true; return; } if (e.KeyCode.Equals(Keys.Right)) { SetFocusOneColumnForward(tb.Name); e.Handled =

Android: What is the KeyEvent.KEYCODE for “?123” key on soft keyboard?

China☆狼群 提交于 2019-12-08 05:22:51
问题 I want to press "?123" key programmatically. But I don't know the KEYCODE for this symbol. And I also unable to find it. Can anybody know the KEYCODE for "?123" symbol on Soft Keyboard. 回答1: It's not an actual key press. It's just a way for the user to change the keyboard layout to be able to press on symbols etc. I think it's not even a guarantee that every keyboard has it. There are many custom keyboards on Android and they can make it any way they want it. You should think for yourself,

KEYCODE_POWER only dispatched on long press

假如想象 提交于 2019-12-08 04:23:38
问题 Why does this key only get dispatched on a long press. Im trying to have it so that normal press of the power button mutes the currently playing audio in the Ringer stream. It only works on long press, normal press turns the screen off. I need it to work on normal press. @Override public boolean dispatchKeyEvent(KeyEvent event) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_POWER: if (ringer == null) return super.dispatchKeyEvent(event); if (!mute) if (ringer.isRinging()) ringer

JavaScript Key Codes

走远了吗. 提交于 2019-12-07 18:35:20
问题 I'm working with a JavaScript routine I didn't write. It is called from a text box's onkeydown attribute to prevent unwanted keystrokes. The first argument is apparently not used. The second argument is a list of characters that should be allowed. function RestrictChars(evt, chars) { var key; var keychar; if (window.event) key = window.event.keyCode; else if (e) key = e.which; else return true; keychar = String.fromCharCode(key); if ((key == null) || (key == 0) || (key == 8) || (key == 9) ||

Are they really the virtual codes?

强颜欢笑 提交于 2019-12-07 06:13:46
问题 Virtual key codes for some keys like shift, [ , ],Del etc are displayed as a different value in java compared to C++/C. For example : Key Java C / C++ Shift 16 160 [ 91 219 ] 93 221 \ 92 220 Del 127 46 Window 524 91 What is the reason for this ? Are these codes the virtual codes or they are a different type ? For the keys including alphabets,numbers,the function keys(F1-F12),backspace,`,etc are the same. I might be misunderstanding a concept,in that case please clarify. Checked in C/C++

How to convert a Windows native virtual key code to Qt::Key?

送分小仙女□ 提交于 2019-12-07 05:32:06
问题 I am working on a program which communicates with a windows native program, so it needs the actucal native virtual key code. How to convert from a Windows native virtual key code to Qt::Key? 回答1: If you have access to a QKeyEvent , key() and nativeVirtualKey may help. From Assistant, qthelp://com.trolltech.qt.472/qdoc/qkeyevent.html#details 回答2: Look in the file qt\src\gui\kernel\qkeymapper_win.cpp 来源: https://stackoverflow.com/questions/7482213/how-to-convert-a-windows-native-virtual-key