keypress

jQuery keypress event wait 0.5 seconds for another user-keypress

孤人 提交于 2019-12-05 14:35:59
I'm currently developing a live search for my website and I want to decrease some unnecessary request with some simple jQuery (of course I have a back-end-flood-control). I've got a keydown-event-listener for my search-field. This listener currenty only fires the ajax command for the php search-function if val().length is >= 3. But now I want an additional condition. So when the length is >= 3, I want to wait for about 0.5s or so if the user is performing another keypress. If he does, the function should not be called and I want the listener to wait another 0.5s and wait again for more user

Catching Backspace on Chrome & Firefox is Different

回眸只為那壹抹淺笑 提交于 2019-12-05 11:17:44
I am trying to make a console like application, so I am catching all the keypress on the window and do related stuff with them(not important). Problem is at backspace. I have the following code: $(window).bind("keypress",function(e){ var code = e.keyCode || e.which; if ( code == 8) { a = $("#console").html(); $("#console").html(a.substring(0,a.length-1)); currentCommand = currentCommand.substring(0,currentCommand.length-1); e.preventDefault(); } However, in Firefox, contents of the #console is deleted but Chrome does not execute the code above. I need a cross-browser compatible solution. What

jQuery .keyPress() - How to get value of input which triggered event?

淺唱寂寞╮ 提交于 2019-12-05 10:55:08
Trying to do some jQuery validation (without the plugin - please no answers like "Just use the validate-js plugin"). I'm wiring up a client-side event handler keypress for each "required field" on doc ready: $(document).ready(function() { $('#myform input.required').each(function() { $(this).keypress(onRequiredFieldKeyPress); }); }); Which correctly fires this event on each keypress: function onRequiredFieldKeyPress() { if ($(this).val().trim() == '') { $(this).next('em').html('*').show(); // show req field indicator } else { $(this).next('em').html('*').hide(); // hide req field indicator } }

jQuery: How to execute code when exiting fullscreen mode with escape button?

半世苍凉 提交于 2019-12-05 10:30:53
Following problem: With my code I enter fullscreen mode by clicking on an image in a list. I moved my next-button and my prev-button to the edge of the screen via jQuery. But after leaving fullscreen mode I want them back in their original position. But how can I detect if the fullscreen mode has been cancelled? Here is my code: HTML: <div id="slider-control-left"><span id="slider-prev"></span></div> <div id="slider"> <ul class="bxslider"> <li><img ... /></li> ... <li><img ... /></li> </ul> </div><!-- end slider--> javascript: $(document).ready(function () { $('.bxslider li img').click

How do you get a widget's children in Qt?

こ雲淡風輕ζ 提交于 2019-12-05 09:25:09
问题 I'm simulating keyPresses to an application through Qt's KeyPress function. All the KeyPresses work fine. However when I pass a QT::Key_Enter which is supposed to press the OK button of the currently active window, or QT::Key_Cancel for the cancel button, it does nothing. I'm thinking maybe, because these buttons don't have the focus, and the parent window itself has it. How do you get the children of a window? or rather find the OK or Cancel button on it so you could set it as the

Daemon in C# to listen for keypress

只谈情不闲聊 提交于 2019-12-05 09:24:49
问题 I'm looking to create a small C# application that will either run as a daemon or sit in the taskbar, and wait for a specific keypress. When the expected keypress is encountered, I'll perform some actions. This is going to be used primarily for quick-posting of data to a web-service I'm writing. I've looked around the net for a while, but my search terms have been too vague, and I haven't come across any concrete examples or guides. Thanks, Mike Trpcic 回答1: I came across this on CodeProject.

C# Simulate VolumeMute press

不羁岁月 提交于 2019-12-05 08:26:26
I got the following code to simulate volumemute keypress: [DllImport("coredll.dll", SetLastError = true)] static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo); byte VK_VOLUME_MUTE = 0xAD; const int KEYEVENTF_KEYUP = 0x2; const int KEYEVENTF_KEYDOWN = 0x0; private void button1_Click(object sender, EventArgs e) { keybd_event(VK_VOLUME_MUTE, 0, KEYEVENTF_KEYDOWN, 0); keybd_event(VK_VOLUME_MUTE, 0, KEYEVENTF_KEYUP, 0); } This code doesnt work. I know there's another way to mute/unmute sound by SendMessageW, but I dont want to use SendMessageW because I use KeyState to

Knockout event binding for input keypress causes weird behavior

余生长醉 提交于 2019-12-05 07:01:08
Long story short, I want to enable users to hit enter on an input element and certain method in my viewmodel be called. Here is my html input: <input id="searchBox" class="input-xxlarge" type="text" data-bind="value: searchText, valueUpdate: 'afterkeydown', event: { keypress: $parent.searchKeyboardCmd}"> and here is my method in vm: searchKeyboardCmd = function (data, event) { if (event.keyCode == 13) searchCmd(); }; everything works fine and searchCmd is called when I hit enter on input, but the problem is that I can type nothing in input, i.e. everything I type into input is ignored. Thank

How to disable/remove only first space on input field?

别来无恙 提交于 2019-12-05 05:58:03
问题 Good morning everybody! I have a case, when I should prevent users to entering space as a first character on input field. I have a demo here: http://jsbin.com/foyetolo/2/edit It works only when you hit spacebar for first time. When you start typing other characters and select whole text in input (ctrl+a) and then hit the space bar it adds the space in the beginning of input field. So, how to check if on keypress/keydown if the first character will be a space, return false and not allow it to

Implementing keyPressEvent in QWidget

家住魔仙堡 提交于 2019-12-05 04:56:17
问题 I have a QDialog window that has a continue button. The continue button is the default button because whenever I press the enter key, the continue button is pressed. I discovered something strange: when I press the enter key three times, the continue button presses three times. However, when I press it a fourth time, the whole window closes. I have a cancel button right below the continue button that closes the window, but I don't make the cancel button the default button or anything. I