enter

Javascript simulate pressing enter in input box

心不动则不痛 提交于 2019-12-12 19:47:46
问题 I have what seemed to be a simple fix to a problem but after trying a ton of different solutions online nothing seems to work for me. I have search field that searches a data table every time you type or press enter in the input field, however after I assigned a value to the search box when the page is loaded it wont do the search until after the user either presses enter in the box or types / deletes a letter. I was just trying to find a solution to simulate hitting enter but it didn't seem

Simulate Enter In JavaScript

自古美人都是妖i 提交于 2019-12-12 10:46:00
问题 I try to simulate Enter in JavaScript in a specific TextArea . This is my code: function enter1() { var keyboardEvent = document.createEvent('KeyboardEvent'); var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? 'initKeyboardEvent' : 'initKeyEvent'; keyboardEvent[initMethod]('keydown', // event type : keydown, keyup, keypress true, // bubbles true, // cancelable window, // viewArg: should be window false, // ctrlKeyArg false, // altKeyArg false, // shiftKeyArg false, //

How to disable the enter key from going second line when onpress?

一个人想着一个人 提交于 2019-12-12 05:08:51
问题 I want the enter key to save the data to database, but whenever I press it will break and create second line, I just want it stay at one line <div id="editable" contentEditable="true">Press enter now</div> 回答1: This is a jquery solution. $('input').on('keypress', function(e){ if(e.keyCode == 13){ e.preventDefault(); } }); 来源: https://stackoverflow.com/questions/16954446/how-to-disable-the-enter-key-from-going-second-line-when-onpress

Enter button works as tab

大兔子大兔子 提交于 2019-12-12 01:41:58
问题 I just have button in a page and nothing else <button>hello</button> When I open the page and press tab it comes to button but instead I want it in such a way that if I hit enter it should come to that button. This is the code that I have written but it is not working $(document).ready(function () { $('.EntTab').on('keydown', function (e) { if (e.keyCode == 13) e.keyCode = 9; return false; }); }); Need help in tackling this. 回答1: Check this! $(function() { $(document).keydown(function(e) { if

C# 线程同步代码

谁说胖子不能爱 提交于 2019-12-12 00:08:58
#define CODE1 using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading; using System.Threading.Tasks; namespace SomeDemo { public class AsyncDemo { public void Run() { MutexTest(); } /// <summary> /// 线程间同步, 可以暂时释放锁 /// TryEnter、Enter用于获取锁 /// Exit用于释放锁 /// Wait用于暂时释放锁,让其他线程获取锁 /// Pulse用于唤醒处于wait状态的线程 /// lock(obj) {...} 等效于 try { Monitor.Enter(obj, ref token); ...} finally { if (token) Monitor.Exit(obj); } /// </summary> private void MonitorTest() { var lck = new object(); var

C#: How to prevent a textbox' content from being scrolled up on Enter?

假装没事ソ 提交于 2019-12-11 03:32:43
问题 I'm trying to resize at run-time a textbox' height when the user presses the "Enter" key. The resizing works well, but the problem arises from the fact that pressing "Enter" brings the text "up" by one line. In other words, if my textbox contained two lines, only the 2nd one would be visible after pressing the "Enter" key. The textbox would be resized correctly, and the carret positionned at the new line, but the whole content of the textbox won't be visible until the textbox has lost focus.

Pressing 'enter' with multiple input boxes

我们两清 提交于 2019-12-11 03:17:26
问题 I have an HTML form with several input boxes and their corresponding enter button. When I type something in the first input box and either press Enter or the button, it works fine. But if I press Enter in the other boxes it works as if it was in the first box. The buttons work OK. Here is the code I have: <script type="text/javascript"> function fn (num) { alert(num); document.getElementById(num).focus(); } </script> </head> <body> <form> <input id="1" type="text"></input> <button onclick="fn

Unable to capture Enter Key

大憨熊 提交于 2019-12-10 21:24:16
问题 I have a simple form by which I take input: 12 Buttons, 1 Textbox (disabled & read-only) this is what I do to handle input Login_KeyDown() is common method I call for all the KeyDown of every UI component & the form itself.. private void Login_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { Application.Exit(); } else if (e.KeyCode == Keys.NumPad9 || e.KeyCode == Keys.D9) { button3.BackgroundImage = Properties.Resources.button_hover; button3.ForeColor = Color.White;

Prevent enter key from triggering button

放肆的年华 提交于 2019-12-10 17:17:18
问题 I have a search input box which when a user presses enter needs to do nothing. I am using EmberJS and Jquery with the below code. Currently it works to disable a pop up from being triggered but for some reason in IE9 when enter is pressed a toggle button becomes in focus. Works fine in Chrome. I've tried tabindex and preventDefault but neither do the trick. if ($el.hasClass('form-control')) { if ( e.which == 13) { this.get('controller').flipit(); } } Thank you. EDIT------ Here is a snippet of

使用JavaScript在文本框中的Enter键上触发按钮单击

送分小仙女□ 提交于 2019-12-10 14:25:13
我有一个文本输入和一个按钮(见下文)。 当在文本框中按下 Enter 键时,如何使用 JavaScript 触发按钮的click事件 ? 当前页面上已经有一个不同的“提交”按钮,因此我不能简单地将该按钮设为“提交”按钮。 而且,如果 只 从一个文本框中按下该按钮,我 只 希望按 Enter 键即可单击该特定按钮,没有别的。 <input type="text" id="txtSearch" /> <input type=" button " id="btnSearch" value="Search" onclick ="doSomething();" /> #1楼 对于jQuery Mobile,我必须要做 $('#id_of_textbox').live("keyup", function(event) { if(event.keyCode == '13'){ $('#id_of_button').click(); } }); #2楼 将按钮设为Submit元素,因此它将是自动的。 <input type = "submit" id = "btnSearch" value = "Search" onclick = "return doSomething();" /> 请注意,您需要一个包含输入字段的 <form> 元素才能完成此工作(感谢Sergey Ilinsky)。