keyevent

Javascript keyevent and JAWS screen reader

邮差的信 提交于 2019-12-21 05:51:03
问题 I have an application that does something (eg alert) each time a spacebar is pressed. This works fine if I am not using JAWS screen reader. However, once I load JAWS screen reader, it does not execute alert when I press the spacebar. I need to use JAWS so I need this to work. Here is the code snippet. $(document).keypress(function(event) { var chCode = ('charCode' in event) ? event.charCode : event.keyCode; if (chCode == 32){ //32 is keyCode for spacebar alert("spacebars!!!"); } }); From my

onKeyEvent & Accessibility Service

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 04:43:12
问题 My users will be using TalkBack enabled or some other Accessible Service. I would like to capture the onKeyEvent events in our App but the event is dispatched to the enabled Accessibility Services. I have created the following basic Accessibility Service. public class Accessibility_Service extends AccessibilityService { private String TAG = Accessibility_Service.class.getSimpleName(); @Override public boolean onKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event

can't fire keypress event when press delete key

坚强是说给别人听的谎言 提交于 2019-12-21 03:32:09
问题 I'm finding that the delete key doesn't fire the keypress event in Chrome, while other keys work. The problem doesn't occur in Firefox, just in chrome, why? Here is my code: document.addEventListener('keypress', function (e) { console.log(e); }, false); 回答1: Use keydown or keyup instead, it captures the delete key (as well as others that keypress doesn't, see http://www.quirksmode.org/js/keys.html) document.addEventListener('keydown', function (e) { console.log(e); }, false); 回答2: keypress

KeyEvents on Form only works in combination with CTRL

醉酒当歌 提交于 2019-12-20 05:58:49
问题 Code: Private Sub KeyHandling(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown Select Case e.KeyCode Case Keys.Left btnPrev.PerformClick() Case Keys.Right btnNext.PerformClick() Case Keys.Up btnFirst.PerformClick() Case Keys.Down btnLast.PerformClick() End Select End Sub The KeyPreview property of my form is enabled. Problem: This code won't do anything, except when I hold the control key. Can anyone explain this? :) 回答1: This is because the cursor keys

JTextField limit input to certains chars only

血红的双手。 提交于 2019-12-19 19:52:38
问题 i'd like to create JTextField with input characters limited to someting like "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYWZZ0123456789+&@#/%?=~_-|!:,.;" so i tried overriding public class CustomJTextField extends JTextField { String goodchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYWZZ0123456789+&@#/%?=~_-|!:,.;"; //... my class body ...// @Override public void processKeyEvent(KeyEvent ev) { if(c != '\b' && goodchars.indexOf(c) == -1 ) { ev.consume(); return; } else super

How does Java dispatch KeyEvents?

浪子不回头ぞ 提交于 2019-12-19 15:07:43
问题 I've read the definite tutorial on key bindings a few times, but my brain cache doesn't seem large enough to hold the complicated processes. I was debugging a key binding problem (turned out I was using the wrong JComponent.WHEN_* condition), and I stumbled upon a concise and hilarious javadoc for the package private javax.swing.KeyboardManager by an (unfortunately) anonymous Java engineer. My question is this: except for KeyEventDispatcher which is checked at the very beginning, does the

How does Java dispatch KeyEvents?

送分小仙女□ 提交于 2019-12-19 15:07:30
问题 I've read the definite tutorial on key bindings a few times, but my brain cache doesn't seem large enough to hold the complicated processes. I was debugging a key binding problem (turned out I was using the wrong JComponent.WHEN_* condition), and I stumbled upon a concise and hilarious javadoc for the package private javax.swing.KeyboardManager by an (unfortunately) anonymous Java engineer. My question is this: except for KeyEventDispatcher which is checked at the very beginning, does the

How to intercept a hard key pressed in a service?

坚强是说给别人听的谎言 提交于 2019-12-19 10:27:37
问题 Is there anyway to intercept that a hard key was pressed by using a service in order to launch an activity? In other words : Is it possible to handle the KeyEvents in the Service? 回答1: There is no general way to listen for the key events of the hardware keys from anything besides the currently active application. Only the CAMERA button event can be detected, via its broadcast Intent . The ACTION_CAMERA_BUTTON is broadcast when the CAMERA button is pressed and is not intercepted by the

Cannot listen to KeyEvent in JavaFX

爷,独闯天下 提交于 2019-12-18 16:08:46
问题 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

Make a KeyEvent in Java only happen once even when key is held

有些话、适合烂在心里 提交于 2019-12-18 09:23:44
问题 I need to know if it is possible to have an action only happen once when a key is pressed, even if that key is held down for some time, and if it is possible, how? This is the code I have for that now: if(e.getKeyCode() == KeyEvent.VK_A) { attack = true; moveX = -5; draw(moveX, moveY); players.get(username).setImageIcon("attack-left"); } This is within the keyPressed method, and in the keyReleased I set moveX to 0. So if A is pressed the image is supposed to 5 units to the left and stop,