onkeypress

How to differentiate between long key press and regular key press?

对着背影说爱祢 提交于 2019-11-27 16:20:12
问题 I'm trying to override the functionality of the back key press. When the user presses it once, I want it to come back to the previous screen. However, when the back key is long-pressed (for, let's say, two seconds or more), I want to exit the application. By now, I have overriden these two methods in my activity: @Override public boolean onKeyDown( int keyCode, KeyEvent event){ if (keyCode == KeyEvent.KEYCODE_BACK) { //manage short keypress return true; } return super.onKeyDown(keyCode, event

How to get text of an input text box during onKeyPress?

久未见 提交于 2019-11-27 11:16:43
I am trying to get the text in a text box as the user types in it ( jsfiddle playground ): function edValueKeyPress() { var edValue = document.getElementById("edValue"); var s = edValue.value; var lblValue = document.getElementById("lblValue"); lblValue.innerText = "The text box contains: " + s; //var s = $("#edValue").val(); //$("#lblValue").text(s); } <input id="edValue" type="text" onKeyPress="edValueKeyPress()"><br> <span id="lblValue">The text box contains: </span> ​ The code runs without errors, except that the value of the input text box, during onKeyPress is always the value before the

how to Send string from Android to PC over wifi

こ雲淡風輕ζ 提交于 2019-11-27 10:58:32
Hello i am working on an android app which requires to send a string over wifi to PC resulting in simulating keyboard keypresses.Any ideas how i can achieve this task ? You would have to write a server program on the PC and use a ServerSocket to accept a connection from and write a thread for your Android phone that uses a regular socket (with the same port as the PC end) and then manage them using DataInputStream and DataOutputStream. You also need to open permissions on your AndroidManifest.xml. For the permissions use this: <uses-permission android:name="android.permission.ACCESS_WIFI_STATE

onKeyPress event not working in Firefox

此生再无相见时 提交于 2019-11-27 09:06:35
I have the following javascript code...Here I am using onKeyPress="someFunction( )" in the body tag to get the keyCode of the key that is pressed. The code is working fine in IE8 but this is not working in Firefox. Please give some solution to this. <html> <head> <title>onKeyPress( ) event not working in firefox..</title> <script> function printDiv() { var divToPrint=document.getElementById('prnt'); newWin=window.open(''+self.location,'PrintWin','left=50,top=20,width=590,height=840,toolbar=1,resizable=1,scrollbars=yes'); newWin.document.write(divToPrint.outerHTML); newWin.print(); //newWin

How to capture Enter key press?

孤人 提交于 2019-11-27 04:10:17
In my HTML page, I had a textbox for user to input keyword for searching. When they click the search button, the JavaScript function will generate a URL and run in new window. The JavaScript function work properly when the user clicks the search button by mouse, but there is no response when the user presses the ENTER key. function searching(){ var keywordsStr = document.getElementById('keywords').value; var cmd ="http://XXX/advancedsearch_result.asp?language=ENG&+"+ encodeURI(keywordsStr) + "&x=11&y=4"; window.location = cmd; } <form name="form1" method="get"> <input name="keywords" type=

jQuery keypress left/right navigation [duplicate]

ぃ、小莉子 提交于 2019-11-26 22:40:10
问题 This question already has an answer here: Binding arrow keys in JS/jQuery 16 answers I want to give my content slider the ability to respond to keypress (LEFT ARROW key and RIGHT ARROW key) feature. I have read about some conflicts between several browsers and operation systems. The user can navigate the content while he is on the global website (body). Pseudo Code: ON Global Document IF Key Press LEFT ARROW THEN animate #showroom css 'left' -980px IF Key Press RIGHT ARROW THEN animate

onKeyListener not working on virtual keyboard

徘徊边缘 提交于 2019-11-26 18:25:57
问题 I don't understand why this piece of code is not working. Only backspace and return key are detected. Listener doesn't fire for any other key. My device is Nexus One. I tried to override activity's OnKeyDown method and that's even worse. The only detected button was hardware back button. I am seeing around a suggestion to use TextWatcher and onTextChanged, while that might work in some cases, it's not a real work around. For example, if textbox is empty, you won't detect if user press

how to Send string from Android to PC over wifi

浪子不回头ぞ 提交于 2019-11-26 17:58:17
问题 Hello i am working on an android app which requires to send a string over wifi to PC resulting in simulating keyboard keypresses.Any ideas how i can achieve this task ? 回答1: You would have to write a server program on the PC and use a ServerSocket to accept a connection from and write a thread for your Android phone that uses a regular socket (with the same port as the PC end) and then manage them using DataInputStream and DataOutputStream. You also need to open permissions on your

How to get text of an input text box during onKeyPress?

回眸只為那壹抹淺笑 提交于 2019-11-26 15:33:46
问题 I am trying to get the text in a text box as the user types in it (jsfiddle playground): function edValueKeyPress() { var edValue = document.getElementById("edValue"); var s = edValue.value; var lblValue = document.getElementById("lblValue"); lblValue.innerText = "The text box contains: " + s; //var s = $("#edValue").val(); //$("#lblValue").text(s); } <input id="edValue" type="text" onKeyPress="edValueKeyPress()"><br> <span id="lblValue">The text box contains: </span> ​ The code runs without

How to handle the `onKeyPress` event in ReactJS?

孤街浪徒 提交于 2019-11-26 15:06:56
How can I make the onKeyPress event work in ReactJS? It should alert when enter (keyCode=13) is pressed. var Test = React.createClass({ add: function(event){ if(event.keyCode == 13){ alert('Adding....'); } }, render: function(){ return( <div> <input type="text" id="one" onKeyPress={this.add} /> </div> ); } }); React.render(<Test />, document.body); I am working with React 0.14.7, use onKeyPress and event.key works well. handleKeyPress = (event) => { if(event.key === 'Enter'){ console.log('enter press here! ') } } render: function(){ return( <div> <input type="text" id="one" onKeyPress={this