keyevent

Overriding lock/power button in android devices

烈酒焚心 提交于 2019-12-06 11:34:59
I would like to know if its possible to override power button in android? I read a lot of posts in Stack Overflow, some saying it's possible and some saying it's not ( example ). What I am trying to achieve is that - when user is using my app he needs to press the lock/power button 5 times to lock the screen. I dont want to override the swtich off functionality only the lock one. Is there anyway to fetch power button callback? I tried WakeLock and disabled the keyguard but it does'nt serve my pupose. I tried out below code from Shink link posted in comments section below: @Override public

How to create a KeyEvent

廉价感情. 提交于 2019-12-06 08:24:04
When i create the KeyListener , it requires the following fields: public void keyPressed(KeyEvent e) { } public void keyReleased(KeyEvent e) { } public void keyTyped(KeyEvent e) { } When i put System.out.println(e) into the keyPressed method, though, it returns this when i press the enter key: java.awt.event.KeyEvent[KEY_PRESSED,keyCode=10,keyText=?,keyChar=?,keyLocation=KEY_LOCATION_STANDARD,rawCode=0,primaryLevelUnicode=0,scancode=0] on javax.swing.JButton[,1,1,100x100,alignmentX=0.0,alignmentY=0.5,border=com.apple.laf.AquaButtonBorder$Dynamic@13b33a0e,flags=288,maximumSize=,minimumSize=

Skipping over Java KeyEvents

余生颓废 提交于 2019-12-06 08:06:05
I have a program where the user can press a key to perform an action. That one event takes a small amount of time. The user can also hold down that key and perform the action many times in a row. The issues is that the keyPress() events are queued up faster than the events can be processed. This means that after the user releases the key, events keep getting processed that were queued up from the user previously holding down the key. I also noticed that the keyRelease event doesn't occur until after the final keyPress event is processed regardless of when the key was actually released. I'd

Override VK_Tab Focus action

余生长醉 提交于 2019-12-05 23:30:47
Good Day! I am tying to add keyevent listener to jTextField so that if the user pressed the tab key, the caret position will go to the end of the text inside the jtextField, here is my code: private void jTextField1KeyPressed(java.awt.event.KeyEvent evt) { if(evt.getKeyCode()==KeyEvent.VK_TAB){ evt.consume(); jTextField1.setCaretPosition(jTextField1.getText().length()); } } But it doesn't work. How can i make this happen? Hovercraft Full Of Eels One way is to: First of all, don't use a KeyListener since this is a Swing application, and you shouldn't use KeyListeners in Swing apps if it can be

CKEditor key event not updating text properly

拜拜、爱过 提交于 2019-12-05 22:48:11
I have the following code to automatically update the content inside a div when the user types it inside a CKEditor textarea: CKEDITOR.instances.editor.on("key", function(e) { var preview = document.getElementById('some-div'); preview.innerHTML = CKEDITOR.instances.editor.getData(); }); The problem is that if I type in "Hello world", in the div it appears "Hello worl" and the "d" doesn't appear until another key is pressed. And I would want the same content in both places. Thanks in advance! I solved it handling the key event in a different way. You can see it below: CKEDITOR.instances.editor

How do I the KeyEvent only once when it is held down?

久未见 提交于 2019-12-05 21:13:46
I am trying to shoot a missile at a certain rate but currently you can simple hold down the fire button (Space) and it will make a continuous line of missiles. I believe this is because the KeyEvent is being triggered when you hold it down when what I need it to do is only trigger once when you hold it down. How would I make it detect the holding down of a button as only pressing it once? public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_SPACE) { fire(); } if (key == KeyEvent.VK_A) { dx = -1; } if (key == KeyEvent.VK_D) { dx = 1; } } public void keyReleased

Press Power button Twice to send SMS

拟墨画扇 提交于 2019-12-05 18:36:42
I have written an app in which the user can send messages whenever they press a button given in the activity, and it works fine for me, but now my target is to send SMS by using double press on power button . but I don't have any idea, how to do that ? Send SMS by using double press on power button below is the code, which I am using to send SMS: btnPanic.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub String message = "My current location is:" + "\t" + currentLocation ; String phoneNo = editContacts.getText().toString();

Handling arrow key events on a winform textbox without overriding

坚强是说给别人听的谎言 提交于 2019-12-05 14:16:25
I have a situation where I'm provided with a WinForms TextBox instance which I want to attach autocomplete functionality to. I've got the autocomplete (string matching + dropdown) all figured out and it works reliable so far. What is the ability to navigate the dropdown with the keyboard (as is the norm with this sort of UI). The natural solution would be to handle KeyDown (or somesuch) event for the textbox and moving the selection in the dropdown accordingly. However, it happens that to do this, you need to override the IsInputKey() event to allow capture of arrow key events. The alternative

Scroll webView with volume keys

为君一笑 提交于 2019-12-04 21:08:38
How do you scroll a webView w/ the volume hard keys? ...and can it be done with easing? If so, how? I'm a nooB to Android - Coming over from ActionScript and any help will be greatly appreciated. my R.id.webPg001 is a WebView id. This is where I'm at now: @Override public boolean dispatchKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event.getKeyCode(); ScrollView scrollView; scrollView = (ScrollView) findViewById(R.id.webPg001); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: if (action == KeyEvent.ACTION_UP) { scrollView.pageScroll(ScrollView.FOCUS_UP);

What triggers (or generates) KeyEvent.ACTION_MULTIPLE?

与世无争的帅哥 提交于 2019-12-04 17:35:44
问题 The documentation for KeyEvent.ACTION_MULTIPLE says: "multiple duplicate key events have occurred in a row, or a complex string is being delivered. If the key code is not {#link KEYCODE_UNKNOWN then the {#link getRepeatCount() method returns the number of times the given key code should be executed. Otherwise, if the key code is KEYCODE_UNKNOWN, then this is a sequence of characters as returned by getCharacters()." But it doesn't say how to actually generate that event. I tried (rapidly)