Menu
  • HOME
  • TAGS

Multiple keys with WPF KeyDown event

c#,wpf,keyboard,keyboard-events,keydown

Use: else if..... In your case both options are fired, because you press the F1 key in both cases....

Preventing default action of keys in browser

javascript,angularjs,keyboard,keydown,keyup

Use 'keydown' rather than 'keyup' keyup Fires when the user releases a key, after the default action of that key has been performed. (http://www.quirksmode.org/dom/events/keys.html)...

keydown event with keys.Enter and keys.Tag

c#,winforms,keydown

Usually, when you press a key, the focused control receives the key pressed. You could change a bit of this flow setting the Form.KeyPreview property to True. With this setting the Form receives the key pressed before the focused control. You are messing with this 'normal' flow trying to insert...

How do i allow/deny a key based on how many times it appears on a listbox?

textbox,listbox,key,keypress,keydown

Ok so with help from some friends i was able to get what i wanted, here is what we did: private bool denykey = false; private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Back) { denykey = false; return; } var countText = 0; foreach (var letter in...

C# pressing key breaks movement of an object

c#,key,keydown,movement

I believe you're relying on the fact that keys get repeated by Windows while you hold them down to make your game pieces move. The first key being held down will stop repeating because the new key being held down is repeating instead. To fix this move the pieces in...

Allow number and paste in input text box

jquery,keydown

You can try HTML5 input event: $('.onlyNumType').on('input', function(e) { // Beware, this will get called even if user hits `CTRL+V`! // In a nutshell, this will be triggered every time input changes. }); However, note that setting value programmatically like $('.onlyNumType').val('Hiya!') will NOT trigger this event....

JavaScript Press Enter Key Twice With Different Actions After Each Keypress

javascript,keypress,keydown

You are throwing away all JS code when you write on "document". You need to put that answer on another element like a , document.getElementById('result') and then write the result to that element. Here is your plunk good sir var enterPressed = 0; window.onkeypress = function (e) { var keyCode...

Pass KeyDown event to other control

c#,.net,winforms,keydown

Any reason you can't just pass the event onto the "child control" ? Below example is KeyPress but the same idea applies for KeyDown //Parent Control Visible private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { richTextBox1_KeyPress(sender, e); } //Child Control Hidden private void richTextBox1_KeyPress(object sender, KeyPressEventArgs e) { richTextBox1.Text += e.KeyChar.ToString();...

Keydown event Javascript?

javascript,jquery,keydown

You need to cancel the event! event.preventDefault(); Just make sure to only do that when you're submitting the form - it'd be very easy to accidentally nuke all ability to type in the textarea at all ;) Also, as a usability hint, I would suggest adding && !event.ctrlKey && !event.shiftKey...

Keydown and keypress events gives different keyCode

javascript,javascript-events,keypress,keydown,keycode

stackoverflow.com/questions/1367700/… explains it well. keydown is only tracking the key itself, not the state of the key. If you press 'A' KeyDown generates a KeyCode of Keys.A and if you press 'shift-A' you also get a KeyCode of Keys.A.

Check if key is already pressed when loading new page (JavaScript)

javascript,jquery,keypress,keylistener,keydown

It is not possible. You need an event "keyup" or "keydown" to be able to know the state of your ALT key after a new page loads. However you can store the state (boolean down or up) in localStorage for example. When a new page loads you can read the...

Can someone help me with this hotkey script?

keydown,hotkeys,pixels,mousemove

#m:: MouseMove, 0, 3, 50, R This will move the mouse cursor down three pixels from its current location at a slow speed. The hotkey (windows key + m) is assigned. Reference: http://www.autohotkey.com/docs/commands/MouseMove.htm...

Remove one-sample capture delay in .keydown()

javascript,jquery,keydown

This is because the event is fired first and processed by your code, then the character is added to the input field. This makes the $('#input').val() return previously entered character. You could use String.fromCharCode(event.which), but this will not distinct different case, you'll have to parse event object for modifier keys...

Detect all the Key Pressed in keyboard

c#,wpf,keydown

If you want to find which keys are pressed, you could do this, if ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt) // Is Alt key pressed { if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.A)) { MessageBox.Show("Key pressed"); } } ...

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

javascript,jquery,events,keypress,keydown

You can do this by checking if key is space and selection start is 0 as below: $(function() { $('body').on('keydown', '#test', function(e) { console.log(this.value); if (e.which === 32 && e.target.selectionStart === 0) { return false; } }); }); Demo Link...

Swift OSX key event

osx,cocoa,swift,keydown

Here is some example code: override func keyDown(theEvent: NSEvent) { if (theEvent.keyCode == 1){ //do whatever when the s key is pressed } } Key codes: ...

keyDown() Not working Processing

processing,keydown

This will won't work without draw function. Also you are declaring new local variable ready inside keypressed() this is bad mistake. Try move your drawing code from "keyDown()" into "drawing" like this: void draw() { if (ready == false) { background(#FFFFFF); //This is needed for redrawing whole scene fill(#FFFFFF); rect(350,...

Keydown event for Pygame

python,pygame,keydown

this is because updated tankX values do not affect the tank object. there are many ways to make it work. for example, inserting a re-initialization of tank in the while True loop: import pygame, sys from pygame.locals import * WINDOW_WIDTH = 800 WINDOW_HEIGHT = 600 TANK_SIZE = 20 BLACK =...

KeyDown is not working, Swift

swift,nsview,keydown

Just confirming... in your code you seem to have overriden KeyUp. So maybe, you should try changing it to: override func keyDown(theEvent: NSEvent) { if theEvent.keyCode == 124 { println("abc") } else { println("abcd") }...

how to fire a keydown or keypress event

c#,winforms,events,keypress,keydown

@Idle_Mind thanks. it works. Posting comment as answer: and I write this codes on Form1_Load The Load() event occurs before the form has been displayed, therefore your keystroke(s) is being sent to whatever application had focus right before your program was run (probably Visual Studio if you're running from...

How to open new form when Enter as Tab?

c#,winforms,keypress,keydown

Here You can wirte as: Control nextControl; if (e.KeyCode == Keys.Enter) { nextControl = GetNextControl(ActiveControl, !e.Shift); nextControl.Focus(); if(nextControl=Combo) { KeyPreview=false; } e.SuppressKeyPress = true; } ...

Alt key behaviour with Javascript on Chrome/Windows 7?

javascript,jquery,html,keydown,keyup

It can be related to how your browser handles the alt key, might be it activates its own menus. Your code works fine for all keys including alt on my ubuntu+chrome. You can also check if e.preventDefault() solves your problem....

C# Form Keydown

c#,forms,keydown

Check if you registered the handler in the object settings.

KeyDown event handler is not working

c#,xaml,windows-8.1,keydown

Try registering an accelerator key instead of a key event on grid (it must have focus to fire the event): http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.core.coredispatcher.acceleratorkeyactivated Example: Window.Current.Dispatcher.AcceleratorKeyActivated += ... ...

Execute action after pressing the keyboard

jquery,keydown

I believe you want .offset().top instead of .position().top. $(window).on('keydown', function (e) { if (e.which != 40) return true; e.preventDefault(); var posicao = $('.homeBaixoRodapeTexto1').offset().top; $('html, body').stop().animate({ scrollTop: posicao }, 1500); }); You have to be real careful with this. You're essentially breaking navigation with the keyboard. Here's a small demo: http://jsbin.com/xecapoyu/3/edit?js,output...

How to filter keydowns with rxjs?

javascript,keydown,rxjs

You can avoid repeated items from an observable (as you see when a key is held) with distinctUntilChanged which filters out values matching the last emitted value (where matching is determined by equality of emitted values or their values transformed by the keySelector callback argument). In your case, this could...

Removing the delay after KeyDown event?

c#,events,keypress,keydown

The answer in the proposed duplicate is incorrect, unfortunately. It doesn't ignore repeated KeyDown events, and so will gradually increase the "delta" value in the direction being handled by each key case. It also doesn't respond to the keypress immediately (i.e. no action happens until the first timer tick). This...

jQuery: trigger event on tab key

javascript,jquery,tabs,keypress,keydown

The problem I think is in the type of event you're trying to listen to. The keypress event is triggered when a char gets written into an input text, while tab key doesn't insert any character. It just blurs the input. Read more here. You might be looking for the...

pygame - Key inputs not working in if not syntax

pygame,keydown

You need to completely rethink your approach. There are 2 good ways of doing key-based input. 1) Have a flag for each key, set it on KEYDOWN, and unset it on KEYUP. 2) Use the currently-pressed keys dictionary that Pygame provides. Then you can say stuff like "if keys["UP"]:". This...

Get keydown event without a textbox

c#,events,keydown

Try with the KeyPress Event of the form. It just works fine. ...

jQuery: How to detect arrow key press only on certain element

javascript,jquery,scroll,keydown,onkeydown

Instead of $(document).keydown(function(e) { in your javascript code have $(<selector>).keydown(function(e) { where <selector> points to the element you want to track. UPDATE Better - since you mention dynamically added elements, use delegation structure of event binding: $(document).on("keydown", ".<yourClassName>", function(e) { ...

Jquery keydown event navigate picture slider

jquery,navigation,slider,keydown

Change the id of radio inputs in this way img_1, img_2, img_3 And execute the following code on document ready. $(document).keydown(function(e) { var checkedElmIdx = parseInt($("[type='radio']:checked").attr("id").split("_")[1]); if(e.keyCode == 37) { // left $("#img_"+(checkedElmIdx-1)).prop("checked", true); } else if(e.keyCode == 39) { // right $("#img_"+(checkedElmIdx+1)).prop("checked", true); } }); ...

mac Swift multiple keyDown events

osx,swift,controls,keydown

The repeated keydown events that occur when a key is held down are generated by the keyboard hardware. On the PC, the protocol definition says: If you press a key, its make code is sent to the computer. When you press and hold down a key, that key becomes typematic,...

How can I trigger a keydown event from code in JavaScript?

javascript,events,keyboard,keydown

Some thing like this should work. var newEvent = $.Event('keydown', { keyCode: event.keyCode }); newEvent.keyCode = $.ui.keyCode.DOWN; $(this).trigger(newEvent); ...

Nested Loop is skipped within Function

javascript,html5-canvas,nested-loops,keydown

The problem doesn't exist in your for loops, but rather your if else structure. You were close with your answer when you noticed that whatever was on bottom ran fine, but what was on top didn't. This was because if your top if statement was caught, the bottom else does...

Change Label text to what is written, when ListView as active object

c#,forms,listview,keydown

You can use the AfterLabelEdit event: private void listView1_AfterLabelEdit(object sender, LabelEditEventArgs e) { yourLabel.Text = e.Label; } Don't forget to hook up the event! If you want to display the new text while typing you can either try to listen to the keyboard between the BeforeLabelEdit and AfterLabelEdit events or...

change value of bars with arrow key down

javascript,css,keydown

You can use setInterval to simulate a key pressed, here and example var intervalID; //through arrow down values are changing// window.onkeydown = function(e){ if(e.keyCode == 40){ if(typeof intervalID == 'undefined') { intervalID = window.setInterval(changeIdValue, 10); } }; } ...

AngularJS Press Key Twice With Different Actions After Each Keypress

javascript,angularjs,keypress,keydown

You are using e.preventDefault(); but e is not defined

Keydown Eventhandler Process

c#,keydown

The KeyDown event gives you the virtual key code of the key that was pressed. Like Keys.A if you press the A-key. It just tells you about the key, not about the letter that's produced by the key. Which depends on the active keyboard layout (it is not an A...

jQuery on TAB pressure simulate on(mousedown) event

javascript,jquery,dom,keydown

$(this).trigger('mousedown') or just $(this).click() and this will trigger whatever event is bound to that element. note that you should do *... that's super bad for performance. Try: $(document).on('keydown.tab', '*', function(e){ if( e.keyCode == 9 ){ $(this).trigger('mousedown'); } return false; }); But you can't really know on which element was the...

How to be able to control the movement of a panel on a UserControl?

c#,forms,focus,keydown

You are almost there the sole problem is focus. However you can still achieve the same without focusing the control by using the PreviewKeyDown event so just change your code to use the same. PreviewKeyDown += PreviewKeyDownHandler; public void PreviewKeyDownHandler(object sender, PreviewKeyDownEventArgs e) { switch (e.KeyData) { case Keys.Right: panel1.Location...

How can I respond to a keyboard chord and replace the entered alpha key with a special one?

c#,winforms,keydown,keycode,modifier-key

Here's one way to accomplish this for all TextBoxes on your Form: public partial class Form1 : Form { public Form1() { InitializeComponent(); } protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (this.ActiveControl != null && this.ActiveControl is TextBox) { string replacement = ""; TextBox tb = (TextBox)this.ActiveControl;...