keyboard-events

catch-all keyup/keydown events in iframe?

三世轮回 提交于 2019-12-01 00:53:15
问题 I'm working on a canvas-based game and am using window.addEventListener() to attach keyup and keydown events globally. This works in when viewing the page normally, but when embedding it as an iframe; it doesn't get the keyup and keydown events. Is there a better way I can do this? 回答1: You can't, not unless the frame has focus. What you can do is make a keydown on the outer window focus the iframe, or always somehow focus the iframe, or focus the iframe by default (might be good enough, not

Sending keypresses to JTextField

笑着哭i 提交于 2019-12-01 00:50:57
I'm trying to simulate text input into a JTextField . I've got a 1 char long string containing the letter I want to add and I run: receiver.dispatchEvent(new KeyEvent(this, KeyEvent.KEY_TYPED, 0, this.shifted?KeyEvent.SHIFT_DOWN_MASK:0, KeyEvent.VK_UNDEFINED, text.charAt(0))); But this doesn't seem to change the contents at all. What am I missing here? Looks like a virtual keyboard to me :-) Almost the exact same code does work for me. I would suggest the following: Pass the target JTextField (in your case, receiver ) as the source parameter to the KeyEvent constructor, i.e.: receiver

Why doesn't GWT let us add key event handlers on document element?

邮差的信 提交于 2019-11-30 22:50:34
I know there's FocusPanel on which I can attach such handlers, but in my experience this component does not behave that well. So I'd like to avoid it as much as possible. So I'm wondering why there's no way to attach key handlers on document too? According to quirksmode.org it works cross-browser, so this shouldn't be a concern. I've also tried writing some JSNI code to do this myself, which works ok for most cases. However, if there's any other widget that listens for the same event as me on document, and that widget lets the event propagate, I can do pretty much nothing with the event that

KeyDown event not raising from a grid

孤人 提交于 2019-11-30 20:25:52
Here I have sample window with a grid. I need to capture event when key is pressed. But it is not raising when I click grid area and then press key. It will work only if Textbox is focused. I know it will work if I capture it from Window. But I have other application with few usercontrols and I need to capture it from distinct ones. I tried to set Focusable.false for Window and true for Grid but it not helps. Any solutions? <Window x:Class="Beta.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow

Equivalent to a keypreview property in WPF

﹥>﹥吖頭↗ 提交于 2019-11-30 19:37:46
I'm pondering taking the plunge to WPF from WinForms for some of my apps, currently I'm working on the combined barcode-reader/text-entry program (healthcare patient forms). To be able to process the barcode characters, I rely on the Keypreview property in WinForms (because barcodes can be scanned regardless of what control has the focus). But I cannot seem to find a KeyPreview property in neither VS2008 or VS2010, for a WPF app. Is there an alternative approach/solution to handle my barcode characters in WPF? Rgrds Henry use the override in your own UserControls or Controls (this is an

Why doesn't GWT let us add key event handlers on document element?

牧云@^-^@ 提交于 2019-11-30 17:46:40
问题 I know there's FocusPanel on which I can attach such handlers, but in my experience this component does not behave that well. So I'd like to avoid it as much as possible. So I'm wondering why there's no way to attach key handlers on document too? According to quirksmode.org it works cross-browser, so this shouldn't be a concern. I've also tried writing some JSNI code to do this myself, which works ok for most cases. However, if there's any other widget that listens for the same event as me on

Cannot listen to KeyEvent in JavaFX

ε祈祈猫儿з 提交于 2019-11-30 13:50:53
I want my JavaFX program to respond to keyboard events. I tried adding listeners to root Pane , to topmost Pane , but it doesn't respond to events! Here is my code: AnchorPane root = new AnchorPane(); root.setOnKeyPressed(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent t) { pressKey(t.getCharacter().charAt(0)); } }); root.setOnKeyReleased(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent t) { releaseKey(t.getCharacter().charAt(0)); } }); root.addEventHandler(EventType.ROOT, new EventHandler<Event>() { @Override public void handle(Event t) { if (t

How to listen for keyboard open/close in Javascript/Sencha?

霸气de小男生 提交于 2019-11-30 12:41:54
I have a HTML5/Javascript (Sencha) app that I have packed into PhoneGap for iOS in XCode. One way or another, I want to be able to listen for the keyboard open/close events and do something accordingly. Is there any way to do this? Keyboard will be automatically invoked while you are focusing textfield, textareafield ... . So you can create listener to the focus event in javascript which is similar to listening to the keyboard open event. Also you can use the blur listener to handle the keyboard close. Thanks. I've encountered the same issue, and I think that the best solution in your case is

How to handle arrow key event in Cocoa app?

旧城冷巷雨未停 提交于 2019-11-30 12:35:10
How to handle arrow key event in Cocoa app? But, but, but...I don't wanna be an NSResponder subclass. @interface AMonitorNotAResponder : NSObject @end @implementation AMonitorNotAResponder { id eventMonitor; // An event monitor object; instance of // private class _NSLocalEventObserver } - (id)init { self = [super init]; if( !self ) return nil; NSEvent * (^monitorHandler)(NSEvent *); monitorHandler = ^NSEvent * (NSEvent * theEvent){ switch ([theEvent keyCode]) { case 123: // Left arrow NSLog(@"Left behind."); break; case 124: // Right arrow NSLog(@"Right as always!"); break; case 125: // Down

How to find the key code for a specific key

烈酒焚心 提交于 2019-11-30 12:14:43
问题 What's the easiest way to find the keycode for a specific key press? Are there any good online tools that just capture any key event and show the code? I want to try and find the key codes for special keys on a mobile device with a web browser, so an online tool would be great. 回答1: $(function () { $(document).keyup(function (e) { console.log(e.keyCode); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> Here's your online tool. 回答2: Just googled