keypress

Close ModalWindow on keypress

牧云@^-^@ 提交于 2019-12-06 01:44:27
问题 I would like to be able to close a ModalWindow when the user presses a key, in my case ESC. I have a Javascript listener for the keypress which calls the click event of the cancel button's ID: jQuery("#"+modalWindowInfo.closeButtonId).click(); Is this the correct way to do it? I am wondering because it works in Chrome but not in FF, but it could be due my specific implementation. 回答1: The 'right' way to do it is to call the server, then close it with the response. You can do this with an ajax

Stop a infinite while loop pressing a key in Matlab

时光毁灭记忆、已成空白 提交于 2019-12-06 01:08:00
I have a while loop, infinite, and I want to stop it when I press a keyboard key. Pseudocode: While(1) do stuff; listening for key; if key is pressed break; end end The function waitforbuttonpress makes me press the key, so no luck. I've found no option on the web. I suppose if you don't want to resort to multithreading (one thread doing the computation in the while loop, another one waiting for input and setting a global sentinel value to break the while loop) you can try to implement breaking the loop on catching a keyboard-interrupt (ctrl-c). This should be possible, albeit in a kinda

Qt Key Pressevent Enter

戏子无情 提交于 2019-12-06 00:56:11
问题 void LoginModle::keyPressEvent(QKeyEvent *event) { qDebug() << event->key() << "\t" << Qt::Key_Enter << "\t" << QKeyEvent::Enter; if( event->key() == Qt::Key_Enter) OKButtonClicked(); else QDialog::keyPressEvent(event); } This code is very simple, class LoginModle inherits from QWidget . run this code and when I press Enter , it shows: 16777220 16777221 10 It means that my Enter in keyboard is 16777220 , but in Qt, it was defined as 16777221 . My system is Elementary OS (Freya), which is

Javascript keyup doesn't work as expected, it executes in instances where I have not removed my finger from a button

╄→尐↘猪︶ㄣ 提交于 2019-12-05 21:54:58
I'm trying to create a simple game in javascript and I'm stuck on how to deal with keys. Small example: function keyUpEvent(event) { alert(event.keyCode); } window.addEventListener("keyup", keyUpEvent, false); I'm running Ubuntu 9.10 and testing it in Firefox 3.5 and Chromium. If I press and release a button instantly I get an alert, which is to be expected, but when I press and hold a button I get a small pause and then a series of alert windows, the expected result is that I only get an alert window when I remove my finger from a button. I reason it has something to do with the fact that

Move PictureBox using Arrow Keys - Handle keyboard events in PictureBox

十年热恋 提交于 2019-12-05 21:01:13
I have a PictureBox where I use the code below to move my object. I need to add a few buttons in the form, however when I start the program the arrow keys navigate through the buttons instead of my input keypresses. I've tried many ways like PictureBox.Focus() and PictureBox.Select() on Form.Load() , and disabling the arrow key navigation completely on this answer here , but my object will not move anymore. private void UpdateScreen(object sender, EventArgs e) { if (Input.KeyPressed(Keys.Right) && Settings.direction != Direction.Left) { Settings.direction = Direction.Right; } else if (Input

Chromium Embedded Framework bind key press

蓝咒 提交于 2019-12-05 19:53:27
I saw this thread on the official forum of Chromium Embedded Framework but it seems that there were no solutions given. To be honest, I'm not comfortable with C++ platform. Could you help me provide a snippet that binds CEF to the webapp. I wanted to control the application using the default controls: ALT + F4 - close F5 - refresh browser Sharadh Short Version: Implement CefKeyboardHandler , specifically OnPreKeyEvent() ClientHandler::OnPreKeyEvent(CefRefPtr<CefBrowser> browser, const CefKeyEvent& event, CefEventHandle os_event, bool* is_keyboard_shortcut) { if (os_event && os_event->message =

python keypress simple game

删除回忆录丶 提交于 2019-12-05 19:24:45
I would like to see on screen a sign, e.x might be (hash) '#'. Sign will have some starting position, let's say (0, 0). I would like to see sign moving right if I press right arrow, left if I press left arrow, etc. So far my code looks like this, and it works for reading pos, but I want to add some kind of "animation" so I can see sign is moving on the screen: !Update: Just to give u a clue, I created "icon" and now when u press right or left, icon moves in desired direction. from msvcrt import getch icon = chr(254) pos = [0, 0] t = [] def fright(): global pos pos[0] += 1 print ' ' * pos[0],

JavaScript equivalent of jQuery's keyup() and keydown()

冷暖自知 提交于 2019-12-05 18:04:11
I have seen this link on stackoverflow: $(document).ready equivalent without jQuery In my context I am using $(document).keydown(Keypress); $(document).keyup(Keyoff); for the functions function Keypress(evt) { if (evt.keyCode == 39) rightpress = true; else if (evt.keyCode == 37) leftpress = true; } //unset function Keyoff(evt) { if (evt.keyCode == 39) rightpress = false; else if (evt.keyCode == 37) leftpress = false; } Is there a javascript equivalent? Like window.onload? Ian In order to use some more "equivalent" to jQuery's on method, you shouldn't use the onkeydown and onkeyup handlers. Use

AngularJS backspace keypress

两盒软妹~` 提交于 2019-12-05 18:01:15
问题 I need to capture user's backspaces inside an input. So I've done this: <input type="text" ui-keypress="{8:'removeTagOnBackspace()'}" ng-model="searchStudent" /> And then, inside my controller I've done this, just to check if it's working: $scope.removeTagOnBackspace = function() { console.log('here'); }; But is not printing anything. What is wrong with this? Is angular able to capture backspaces? 回答1: Got it! <input type="text" ng-keydown="removeTagOnBackspace($event)" /> And: $scope

Detecting SINGLE key presses in CONSOLE C#

风流意气都作罢 提交于 2019-12-05 16:23:24
I'm new to coding and have decided to start with C#. I've decided to write a simple console program that will detect key press and if only Enter is pressed, it will show number. The problem is that you can just hold down key and it will continue to show numbers. What should I add to my code so program will detect only SINGLE presses and ignore if user is HOLDING the key? (I didn't find anything about this issue for CONSOLE C# , only for Forms one. Neither on this forum, nor in Web at all) Thanks in advance static void Main(string[] args) { Console.WriteLine("Press Enter to play!"); int num = 0