keyevent

JavaFX TextField text validation

ぃ、小莉子 提交于 2020-07-03 20:19:17
问题 I have a listener applied to my field: nameTextField.addEventHandler(KeyEvent.KEY_TYPED, fieldChangeListener(50)); Event handler: private EventHandler<KeyEvent> fieldChangeListener(final Integer max_Lengh) { return new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { TextField field = (TextField) event.getSource(); String text = field.getText(); // I need here something like: if(KeyEvent.VK_ENTER){ // do special part for ENTER KEY } } } } Problem is KeyEvent event is

Trigger backspace key in jQuery

我只是一个虾纸丫 提交于 2020-05-15 08:07:10
问题 How can I trigger the backspace key event in jQuery? The following example isn't working: var e = jQuery.Event("backspace", { keyCode: 8 }); $("#myarea").trigger( e ); 回答1: You can't actually trigger it. You could, for example, remove the last character from a certain input, but you can't trigger the actual key. Example: var str = $('#input').val(); $('#input').val(str.substring(0, str.length - 1)); 回答2: You can't trigger the backpace key. With the jquery caret plugin, you can simulate the

Trigger backspace key in jQuery

末鹿安然 提交于 2020-05-15 08:07:10
问题 How can I trigger the backspace key event in jQuery? The following example isn't working: var e = jQuery.Event("backspace", { keyCode: 8 }); $("#myarea").trigger( e ); 回答1: You can't actually trigger it. You could, for example, remove the last character from a certain input, but you can't trigger the actual key. Example: var str = $('#input').val(); $('#input').val(str.substring(0, str.length - 1)); 回答2: You can't trigger the backpace key. With the jquery caret plugin, you can simulate the

KeyEvent getRepeatCount() always return 0

二次信任 提交于 2020-05-15 06:16:51
问题 I'm working with remote android TV To catch event when use press remote button I use this code: public boolean dispatchKeyEvent(KeyEvent event) { Log.d("LOG", "Number repeate count = " + event.getRepeatCount()); if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_1: exoPlayerManager.showControllerView(); if (event.getRepeatCount() > 0) { if (videoPlayerView.getPlaybackControlView().getPlayer().getPlaybackParameters().speed >= 64) { ((TextView

Power key event in android?

こ雲淡風輕ζ 提交于 2020-01-30 03:31:48
问题 I want to listen to power key event. How can I do that? Currently the code I am using is this: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if(KeyEvent.KEYCODE_POWER == event.getKeyCode()){ Log.e("POWER", "pow"); return true;//If event is handled, falseif } return super.onKeyDown(keyCode, event); } And the user permissions <uses-permission android:name="android.permission.PREVENT_POWER_KEY" /> I do not get any result. I want a add a functionality when user presses power

Java KeyListener keyPressed method fires too fast

亡梦爱人 提交于 2020-01-28 02:28:09
问题 If you use the java KeyListener class you know that if you hold down a key keyPressed will fire one KeyEvent , and then about half a second later will fire the same key many times very very fast. I would like to know if there is a way to keep the KeyEvents from firing too fast. I would like them to be at a nice constant rate of about once every 500 ms. 回答1: You can, but the trick is to not slow down the firing of events, but to slow down how fast you process them: KeyListener kl = new

Java KeyListener keyPressed method fires too fast

我怕爱的太早我们不能终老 提交于 2020-01-28 02:27:13
问题 If you use the java KeyListener class you know that if you hold down a key keyPressed will fire one KeyEvent , and then about half a second later will fire the same key many times very very fast. I would like to know if there is a way to keep the KeyEvents from firing too fast. I would like them to be at a nice constant rate of about once every 500 ms. 回答1: You can, but the trick is to not slow down the firing of events, but to slow down how fast you process them: KeyListener kl = new