onkeypress

Javascript for replacing an abreviation by his equivalent

怎甘沉沦 提交于 2019-12-31 05:09:27
问题 I met some trouble with a javascript. In fact I have in my database many records that are abreviations and ther equivalent, for example, replace tel => telephone etc... So I have this function $('#tags').keyup(function(e){ var code = e.which ? e.which : e.keyCode; console.log(code); if (code == 'tel'){ var input = this.value; input = input.substr(0, input.length -1); console.log(input); input += 'tel'; this.value = input; } }); Actualy this does not work the trouble is that I do not have aby

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

C++ cin keypress event

孤街醉人 提交于 2019-12-30 06:57:11
问题 I believe this is a very simple question, but I can't find a simple answer to it. I have an infinite loop, e.g. while(1) , for(;;) , and I need to break from the loop on a keypress. What is the easiest way to do this? P.S.: I can't use getch , cin.ignore , or cin.get because it stops the loop. 回答1: Well, what you want is asynchronous input. All of the methods provided by cin wait for enter. You will have to use system-specific functions for that, or use a library that will do it for you. What

onkeypress on a <a> tag

南楼画角 提交于 2019-12-24 08:17:45
问题 I'm trying get my <a> tag triggered when the user press on the "enter" key. (onkeypress) . my <a> tag: <a href="javascript:search()" onkeypress="return runScript(event)"> this is my javascript : function runScript(e) { if (e.keyCode == 13) { alert("dssd"); return false; } } I dont know whats messed up ? 回答1: its work for me <a href="javascript:search();" onkeypress="return runScript(event);">Open in new window using javascript</a> javaScript window.runScript = function (e) { if (e.keyCode ==

Avoid Beep sound when enter keypress in a textbox

不想你离开。 提交于 2019-12-23 08:33:50
问题 When you create an aspx page as this one: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:TextBox ID="TextBox2"

detecting ctrl+tab key press in javascript/jQuery

↘锁芯ラ 提交于 2019-12-22 12:33:08
问题 I have a requirement wherein I must restrict the user viewing my web page. Users should not be allowed to press Ctrl + Tab before finishing a task in the page. Is there a way to detect Ctrl + Tab keypress in javascript/jQuery? 回答1: This code will detect CTRL+Tab: $(document).keydown(function(e) { if (e.ctrlKey && e.which == 9) { alert("CTRL + TAB Pressed") } }) Note however that CTRL+Tab functionality is controlled by the browser and you cannot stop it as this fiddle will demonstrate if you

Javascript fires two events - onkeypress and onclick

自古美人都是妖i 提交于 2019-12-21 15:18:12
问题 Problem is when I press a key over a radio button, element MyFunc fires twice - once for "onkeypress" event, another time for "click" event. Question "Why?" I need to handle this by two different ways, but now I can not recognize what initial event was. When I click a mouse it fires just for "click" event. <ul> <li> <input type="radio" onkeypress="MyFunc(event, this)" onclick="MyFunc(event, this)" name="myList" id="MyId_1" />Topic 1 <input type="radio" onkeypress="MyFunc(event, this)" onclick

Using charcode to allow only numbers and enter key

血红的双手。 提交于 2019-12-18 18:31:16
问题 I have this syntax: <input onkeypress="return event.charCode >= 48 && event.charCode <= 57"> I use it on inputs to allow only numbers. But now i need to allow the enter key too since i can no longer use a button to submit the form(personal reasons).By now i found this: event.charCode = 13 // allows enter key but i can't seem to find how to build the onkeypress syntax.Any help ? Thank you. 回答1: you can try: onkeypress="return event.charCode >= 8 && event.charCode <= 57" In this way you can

keyPressEvent.getCharCode() returning 0 for all special keys like enter, tab, escape, etc

本小妞迷上赌 提交于 2019-12-17 22:22:09
问题 My code: @Override public void onKeyPress(KeyPressEvent event) { if (event.getCharCode() == KeyCodes.KEY_ENTER) { registerButton.click(); } } This is attached to a TextBox, and it does fire when I press enter. event.getCharCode() is just zero, not 13 . When I press tab, it's 0 , and when I press escape, it's 0 . Argh! This was working properly yesterday, and something has changed somewhere else in the project to affect this - but I'm not sure what it could be. It really seems like no relevant

Trying to catch the Volume onKeyLongPress() not working

十年热恋 提交于 2019-12-17 21:04:24
问题 I'm trying to get my app to react to a long key press on volume down with the following code: public boolean onKeyLongPress(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { Log.w("myApp", "LONG PRESS"); } return super.onKeyLongPress(keyCode, event); } However, it only spams a bunch of onKeyPress() events for volume down, and onKeyLongPress() never gets called. My intention is to leave the volume down and up "short" presses alone, and have my app react differently