onkeydown

Issue with javascript onkeydown - event.which give characters in upper case only

只谈情不闲聊 提交于 2019-12-30 09:53:24
问题 I have written a piece of javascript code to get the key pressed within a text area. I have used the onkeydown event to capture the key pressed and am calling a function when the event is triggered. Within the function i am using event.which to get the key pressed. But this is not giving the correct key pressed. For any character pressed, it gives the Ascii value of the corresponding upper case character ( 65 to 90 only ). It is not giving Ascii values for the lower case characters, ie 97 to

Activate a Javascript function with a keypress [duplicate]

你离开我真会死。 提交于 2019-12-25 18:27:04
问题 This question already has an answer here : Handle key using javascript onkeydown (1 answer) Closed 6 years ago . function addone() { document.getElementById("subtract").disabled=false; x += 1; document.getElementById("result").innerHTML="Doshi has said OK " + x + " times." if(x == 1 ){ document.getElementById("resetall").disabled=false; document.getElementById("reset").disabled=false; document.getElementById("result").innerHTML="Doshi has said OK " + x + " time." } if(x == 0){ document

Activate a Javascript function with a keypress [duplicate]

╄→гoц情女王★ 提交于 2019-12-25 18:26:15
问题 This question already has an answer here : Handle key using javascript onkeydown (1 answer) Closed 6 years ago . function addone() { document.getElementById("subtract").disabled=false; x += 1; document.getElementById("result").innerHTML="Doshi has said OK " + x + " times." if(x == 1 ){ document.getElementById("resetall").disabled=false; document.getElementById("reset").disabled=false; document.getElementById("result").innerHTML="Doshi has said OK " + x + " time." } if(x == 0){ document

Keep activity alive in background until user doesn't kill or close app?

此生再无相见时 提交于 2019-12-25 16:55:06
问题 Can I keep Android activity alive in background, until user doesn't kill or close the application. I want to detect user clicks in background some specific hardware button clicks, as onKeyDown is not available in service, I need to keep my activity alive in background until user kills the app. Does android allows such behavior ? Update : I was able to solve this using following approach : 1] Use foreground service, Ref : https://developer.android.com/guide/components/services.html#Foreground

Image change on pressing keyup and keydown

只愿长相守 提交于 2019-12-24 06:21:02
问题 I am new to JavaScript and this community. I apologize if this has been asked before, but the threads I found for this topic did not really help me with this specific problem. I would like to achieve the following working: Image 1 is displayed. If you press the left arrow key (keydown) the image should change to image 2. If you stop pressing (keyup), it should change to image 3. If you press the right arrow key it should change to image 4 and on keyup, change to image 5. The code is: <img src

Android: intercepting back key

偶尔善良 提交于 2019-12-23 15:36:10
问题 since the back key destroys my application and all data will be lost I need to intercept it to ask the user if that is really what he wants. I thought of the following structure: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { // ask user if he really wants to exit // no --> return true; // yes --> return super.onKeyDown(keyCode, event); //manually entering either of the return values works fine } return

Android onkey - dispatchKeyEvent not firing

跟風遠走 提交于 2019-12-23 09:49:37
问题 well, I've tried all the solutions I could find on stackoverflow and in other places, but the end result hasn't changed one bit: the only key that triggers the onKey event or the dispatchKeyEvent is the enter key on the virtual keyboard, and only if pressed twice. I cannot intercept any other key (there's a breakpoint at the top of the event and eclipse never stops on it, except for in case of the aforementioned enter). Beheaviour is the same on both emulator and real device. Any ideas? Thank

keycode shortcut each function

隐身守侯 提交于 2019-12-23 04:44:00
问题 I'm working yet on a small script to capture keyevents and easily bind functions on them. But I'm stuck for now! The problem is, that if I initalize more than one "eventhandler" it overides arguments from the first initialization. Thousands of words do not say more than some lines of code. So, here's what I've done so far: var keyCodes={a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,"0":48,"1":49,"2":50,"3":51,

Android wear activity onKeyDown is not getting called

旧城冷巷雨未停 提交于 2019-12-23 03:20:30
问题 This is not a duplicate but a specific case to Android wear. I am trying to make Android wear app do something when certain gestures are performed. But I realized that the onKeyDown() event is not called at all. Any help or info I this regard is useful. Here is my simple code snippet. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gesture_ema); Log.d(TAG, "Inside on create"); //Show prompt window on top

Detect Ctrl + C and Ctrl + V in an input from browsers

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 13:53:27
问题 I am using the direct following and I do not detect the copy and paste with the keys inside the input, would someone know how? Thank you! export class OnlyNumberDirective { // Allow decimal numbers. The \, is only allowed once to occur private regex: RegExp = new RegExp(/[0-9]+(\,[0-9]{0,1}){0,1}$/g); // Allow key codes for special events. Reflect : // Backspace, tab, end, home private specialKeys: Array<string> = [ 'Backspace', 'Tab', 'End', 'Home', 'Delete', 'Del', 'Ctrl', 'ArrowLeft',