keypress

Have to click before pressing key

爱⌒轻易说出口 提交于 2019-12-11 02:36:52
问题 I've finally managed to get my GraphicsProgram in java to remove a certain GObject when the spacebar is pressed. This is the code: public void keyPressed(KeyEvent key){ int space = key.getKeyCode(); if (space == KeyEvent.VK_SPACE){ remove(welcome); } } The problem is that if I start my program, it will not recognize that I am inside the GraphicsWindow program that starts up. (This is somewhat difficult to explain) Basically, I first have to click inside the window, before it will recognize

How to differentiate between 'right click using mouse' AND 'context menu key press on physical keyboard'

喜你入骨 提交于 2019-12-11 02:21:56
问题 How do I differentiate between right click using mouse and context menu key press on a physical keyboard? Using this code I tried printing event in console $('#'+inputId).bind('contextmenu', function(e) { console.log(e); }); I grabbed some output for the above code- For right click using the mouse it is- button: 2 originalEvent: MouseEvent type: "contextmenu" which: 3 For context menu key press on the keyboard it is- button: 2 originalEvent: MouseEvent type: "contextmenu" which: 3 I want to

How can I capture a key press, outside of the form?

为君一笑 提交于 2019-12-11 02:10:43
问题 I have been trying to capture the keys pressed outside of my winform, but obviously a KeyPress event won't work. I haven't been able to get any closer than the KeyPress event, which only works on the form level, as specified I suspect that I will have to do the [DllImportAttribute("user32.dll")] , but I have little to no experience with that. 回答1: Being able to capture key presses anywhere requires using Hooks. There is a library on CodePlex which simplifies implementing Application and

Java - Detecting any key press with KeyBindings?

帅比萌擦擦* 提交于 2019-12-11 01:40:13
问题 I read that it is better to use KeyBindings than KeyListeners. I see how KeyBindings are useful for a specific reaction to a specific key; but I am also trying to detect the press/release of ANY key on the keyboard: is there a way to do this with KeyBindings? For example, I would use KeyBindings normally to act on a single key as so: InputMap iMap = component.getInputMap(); ActionMap aMap = component.getActionMap(); iMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enter without

wxPython: binding wx.EVT_CHAR_HOOK disables TextCtrl backspace

谁说胖子不能爱 提交于 2019-12-11 01:33:42
问题 I have a wx.TextCtrl and I want to be able to type in it, but also detect key presses such as UP, DOWN, RETURN, ESC. So I binded wx.EVT_KEY_DOWN to recognize any key press, and wx.EVT_CHAR_HOOK to do the same thing even when TextCtrl has focus. self.Bind(wx.EVT_KEY_DOWN, self.keyPressed) self.Bind(wx.EVT_CHAR_HOOK, self.keyPressed) Key presses UP, DOWN, RETURN, ESC were recognized and working fine, but due to binding EVT_CHAR_HOOK I cannot use LEFT RIGHT BACKSPACE SHIFT anymore when I type in

how to detect an F5 refresh keypress event in jquery?

倖福魔咒の 提交于 2019-12-10 23:57:55
问题 I noticed that jquery has a keypress function. But it seems that it can only detect keypress event of numbers and characters. It cannot detect the F5 keypress event. And What surprises me the most is everyone online says that the keyCode of F5 is 116, But when I use the jquery keypress function, it just shows that the character t has the keyCode of 116(it seems that 116 is the ascii code of lowercase t)! Can somebody give me any idea about this and how to detect the F5 event in javascript or

Detecting a key press

可紊 提交于 2019-12-10 22:36:30
问题 I am currently checking the keyboard state in my program: SlimDX.DirectInput.KeyboardState keyboardState = keyboard.GetCurrentState(); And detecting key presses like this: if(keyboardState.IsPressed(SlimDX.DirectInput.Key.Q))... I can't figure out how to detect ANY key press, rather than specific keys. I can't put my finger on it after trawling through the SlimDX API documentation. I'm probably missing something really simple no doubt. 回答1: KeyboardState class has a PressedKeys read-only

button click event is triggered after keypress using jQuery

被刻印的时光 ゝ 提交于 2019-12-10 19:01:36
问题 I have these codes $('#search-button').keypress(function (e) { if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) { search(); }; }); $('#search-button').bind('click', function () { search(); }); under the search module I have an alert, now whenever I press Enter when the button is in focus, the search() under the click event also triggers. Please help. Thanks. 回答1: Pressing enter does fire the keypress event - but also triggers the button's 'click' event, so you get search

Body stop scrolling after keydown, keypress with jQuery

自作多情 提交于 2019-12-10 18:04:25
问题 I have some scrolling actions after keydown, keypress pressing. So this is what it looks like: $(document).keydown(function(e) { e.stopPropagation(); if (e.keyCode === 40) { // some scrolling actions in specifie div } else if (e.keyCode === 38) { // some scrolling actions in specifie div } }); Everithing is working fine but when im scrolling, keypressing with my div scrolls also whole page. Is there any option to stop this body scrolling? 回答1: You need .preventDefault() in there... $(document

Programmatically Simulate Keyboard Events on the iPhone

て烟熏妆下的殇ゞ 提交于 2019-12-10 17:25:16
问题 I was wondering if it would be possible to simulate keyboard events - like key down and key up characters - and send them to the iOS device. Basically, I want to simulate a user pressing a key on the keyboard. 回答1: have a look at "Automated GUI testing for iOS", for example Automated testing for iPhone and How about UI automation testing for iOS app with instruments & Javascripts You might not want a full blown automated test solution, but that way you can simulate your keyboard events. There