keyup

Cmd Enter keyup combination detection using javascript

谁都会走 提交于 2019-12-06 14:29:24
问题 I'm using a keyup detection into all my forms to detect the enter button. This is easy, when you are focused in a form's input if you hit enter and the event keyCode is equal to 13 then the form submitted. But now I want to detect the Cmd + Enter combination, because when you are focused in a textarea, the enter button is a line break. So how my detect statement should look like? Thank you 回答1: You mean ctrl with Cmd ? Then check if event.ctrlKey is true: if (event.ctrlKey && event.keyCode ==

How to count numbers of line in a textarea

梦想与她 提交于 2019-12-06 11:31:56
I want to make a dynamic textarea, it should increase in rows as the content increase. I am using this code: $("#text_textarea").keyup(function(e) { //splitting textarea value wrt '\n' to count the number of lines if ($(this).val().lastIndexOf('\n')!=-1) var x = $(this).val().split('\n'); $(this).attr( "rows" , x.length+1 ); }); But it fails when user continues to write without giving any new line \n (pressing Enter). var keyUpTimeout = false; // Required variables for performance var keyupTimer = 0; $("#text_textarea").keyup(function(e) { var cooldownTimeout = 500; //Set the cooldown time-out

How to get the key TAB event on an input element?

纵然是瞬间 提交于 2019-12-06 08:54:16
I try to trigger a button when in an input field the return key has been hit. This works. But if I hit the tab key nothing is triggered because the TAB key event isn't captured. Fiddle example Here is my JQ code snippet for example: $("input[name=input]").on("keypress, keydown, keyup", function(e) { var code = e.keyCode || e.which; if ( code == 13 || code == 9 ) { $("input[name=btn]").trigger("click"); } }); I can't figure out how to get the tab key stroke working like a return key stroke. Use Event.preventDefault() to prevent the browser switching focus on Tab press. Listen for "keydown"

Cell in editmode doesn't fire OnKeyDown event in C#

时间秒杀一切 提交于 2019-12-05 16:05:19
I've made own datagridview control which ovveride OnKeyDown event: public partial class PMGrid : DataGridView { protected override void OnKeyDown(KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { e.SuppressKeyPress = true; //suppress ENTER //SendKeys.Send("{Tab}"); //Next column (or row) base.OnKeyDown(e); } else if (e.KeyCode == Keys.Tab) { base.OnKeyDown(e); this.BeginEdit(false); } else { base.OnKeyDown(e); } } } When I click on datagridview and press Enter it works perfect because row isn't changed and KeyUp event is fired. But when I press Tab, next cell is selected and it is changed to

Limit the number of characters in a WYSIWYG Editor (NicEdit)

久未见 提交于 2019-12-05 08:19:08
I have this jQuery code: var char = 60; $("#counter").append("You have <strong>" + char + "</strong> char."); $("#StatusEntry").keyup(function () { if ($(this).val().length > char) { $(this).val($(this).val().substr(0, char)); } var rest = char - $(this).val().length; $("#counter").html("You have <strong>" + rest + "</strong> char."); if (rest <= 10) { $("#counter").css("color", "#ff7777"); } else { $("#counter").css("color", "#111111"); } }); It works fine! But if instead a val() I have text() it doesn't work. The problem is that at the end of available char it start to replace the text from

Cmd Enter keyup combination detection using javascript

做~自己de王妃 提交于 2019-12-04 19:14:29
I'm using a keyup detection into all my forms to detect the enter button. This is easy, when you are focused in a form's input if you hit enter and the event keyCode is equal to 13 then the form submitted. But now I want to detect the Cmd + Enter combination, because when you are focused in a textarea, the enter button is a line break. So how my detect statement should look like? Thank you You mean ctrl with Cmd ? Then check if event.ctrlKey is true: if (event.ctrlKey && event.keyCode == 13) { alert('now'); } Also see this example . P.s: there are also the booleans event.altKey for alt , event

jquery: percentage of two numbers

瘦欲@ 提交于 2019-12-04 01:21:06
问题 EDITED Thank you for everyone who offered support... the best working script I will share with you in hope that I could help others who is looking for the same solution: $(document).ready(function(){ $("#price1, #price2").keyup(function() { var priceOne = parseFloat($("#price1").val()); var priceTwo = parseFloat($("#price2").val()); var rate = parseFloat($("#rate").val()); if ($("#price1").val() && $("#price2").val()){ $('#rate').val(((priceTwo - priceOne) / priceOne * 100).toFixed(2)); } });

Detecting keydown and keyup events on Linux C++ [duplicate]

爱⌒轻易说出口 提交于 2019-12-01 11:36:01
Possible Duplicate: Access Keystrokes in C Monitoring Keyboard keys in Ubuntu I want to detect and time stamp every keydown and keyup event in a program (Yes, I mean keydown and keyup not just keypress) along with what key was pressed. I could do this by using an APi such as GTK, but I want to get as simple and low level as possible in order to avoid overhead from the libraries affecting the times as well as writing less code. I have been googling this for a while and so far have found a ton of stuff about how to do it on Windows, which doesn't help me since I am using a Linux system, and how

keyup event is working slow performance

浪尽此生 提交于 2019-12-01 11:01:41
My example: $(document).on('keyup', '[contenteditable=true]', function (e) { let _this = $(this), text = _this.text(); if (text.length === 1) { let span = $('<span>').text(text); _this.html(span); } console.log(_this.html()); }); [contenteditable=true] { border: 1px solid #ccc; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script> <div contenteditable="true"></div> My problem: If I type some text (more than 1 character) with normal speed into the div, code works fine. But, when I try to type text with fast speed, no <span> tag was appended to the div. How

Detecting keydown and keyup events on Linux C++ [duplicate]

安稳与你 提交于 2019-12-01 08:38:26
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Access Keystrokes in C Monitoring Keyboard keys in Ubuntu I want to detect and time stamp every keydown and keyup event in a program (Yes, I mean keydown and keyup not just keypress) along with what key was pressed. I could do this by using an APi such as GTK, but I want to get as simple and low level as possible in order to avoid overhead from the libraries affecting the times as well as writing less code. I