Menu
  • HOME
  • TAGS

Javascript keycode clash: “right arrow” and “single quote”

javascript,keycode

When the user presses the single quote key, the e.keyCode property is zero, and the e.which property is 39. Executing String.fromCharCode(39) returns a single quote. You want the keyCode if that property is in the event object: var keycode = "keyCode" in e ? e.keyCode : e.which; That way you...

addEventListener keyup Keydown with Keycode not working [closed]

javascript,addeventlistener,keycode

Try bind event to document or window. If an element is not focusable and is not focused, keyboard events won't dispatch to it, instead they dispatch to document root(<body>).

Key typed event: getKeyCode() returns 0

java-8,keylistener,keyevent,keycode

key typed events: the getKeyCode method always returns VK_UNDEFINED which returns 0. If you want to know when any key is pressed or released, you need to implement keyPressed() or keyReleased() key pressed and key released events, the getKeyCode method returns the event's keyCode See KeyEvent...

jQuery: Need to prevent repetitive 'space bar' input

jquery,forms,input,keycode

Figured out a better way to do this without any counters or anything - AND it can be done with pure Javascript JQuery $('#myInput').on('keydown', function(e){ if(e.keyCode == 32 && $(this).val().indexOf(' ') >= 0){ $('#key').text('Already a space!'); return false; } }); Javascript Equivalent document.getElementById('myInput').onkeydown = function(e) { if(e.keyCode == 32 &&...

Why pygame keycodes are os-specific?

python,input,keyboard,pygame,keycode

Let me preface this by saying I don't have any experience with input on windows or mac systems, but here is whats happening on the linux side. Key events typically follow a three stage processing before reaching a program. The keyboard generates a scancode. The OS converts the scancode into...

Java Robot class press special letter?

java,keycode,robot

'a' evaluates to 97 in UTF-8. KeyStroke.getKeyCode() simply returns an integer representation of 'a'....

Insert four spaces instead of tab

javascript,jquery,html,keycode

Your code works fine but you simply put caret to the wrong place. Change the last line to: this.selectionStart = this.selectionEnd = start + spaces.length; DEMO: http://jsfiddle.net/qdqrs3cw/...

combination of keycode of in unix environment [closed]

linux,keyboard,key-bindings,keycode

GNU/Linux has showkey it ships with package kbd in Fedora....

uncaught referenceError: sKey is not defined onkeydown in chrome

jquery,html5,keycode

I wasn't able to recreate your specific error, but I was getting an error caused by invalid syntax in your subfunction. function logKey(event) { var l = event.keyCode; if(l == 13) { document.mainF.loginBtn.click(); } }); should be function logKey(event) { var l = event.keyCode; if(l == 13) { document.mainF.loginBtn.click(); }...

jQuery/Svg : increment value “dur” when key is pressed

javascript,jquery,svg,increment,keycode

change the following lines var getTheSpeed = parseInt(document.getElementById("object").getAttribute("dur").slice(0,-1), 10); (this will remove the s from the current value of "dur" using slice(0,-1)) and document.getElementById("object").setAttribute("dur",String(getTheSpeed) + "s"); (this will set the new incremented value with an s added to it using string concatenation + "s") Check this out--hope it helps^^ window.addEventListener("keydown",...

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.

keyCode displaying incorrect code value in Angularjs

javascript,angularjs,keycode

I think what you're looking for is ng-keyup instead, this will work for you: <input type="text" placeholder="Search" ng-click="searchPop($event)" ng-keyup="typingMainSearch($event)"> According to Mozilla the keyCode property of keypress is deprecated. Also - this is why you saw 97 when clicking 'a' for instance (taken from the Mozilla link): The Unicode reference...

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;...

List of hex keyboard scan codes and USB HID keyboard documentation

keyboard,hex,hid,keycode,kali-linux

The "scan codes" (they are really indexes to usage codes) are published on usb.org in the USB HID Usage Tables specification in Chapter 10 "Keyboard/Keypad Page (0x07)". A typical keyboard report layout can be found in the USB Device Class Specification for HID in Appendix B "Boot Interface Descriptors", section...

fire a button with pressing ENTER after coming with TAB to it

javascript,html,tabs,enter,keycode

here is my solution: part of HTML, close button is a div element and is a part of a modal window: ... <div class="closeButton"> <span id="closeSpan" tabindex="0">Close</span> </div> ... JS, within the ModalWindow class: $(modWin).find("#closeButton").one("click", this.close).keypress(this.doNothing); this.close = function () { $("#modalWindow").css("display","none").fadeOut(200).html(""); $("#modalWindow #closeButton").hide(); $(window.self.document.body).find("#modalWindow").remove(); } this.doNothing = function (e)...

Can't use KeyCode in C#

c#,keycode

Instead of using KeyPress, use the KeyDown event. KeyPress event will only fire on printable characters, and PrintScreen is not one of them, so it only exposes the KeyChar property, while KeyDown or KeyUp will expose the KeyCode. private void Form1_KeyDown(object sender, KeyEventArgs e) { if(e.KeyCode == Keys.PrintScreen) { MessageBox.Show("Test");...

How to execute a JS code block on pressing ESC key?

javascript,keycode,event-listener

You could use jQuery and do the following: $(document).keyup(function(e) { if (e.keyCode == 27) { $(".modalOverlay").css('visibility', 'hidden'); } }); JSFiddle Or in pure JavaScript: document.onkeydown = function(evt) { evt = evt || window.event; if (evt.keyCode == 27) { document.getElementById("modal").style.visibility = "hidden"; } }; JSFiddle...

How can I get original character?

c#,events,keycode

If you insist on using KeyDown Event This is what you need. private void textBox1_KeyDown(object sender, KeyEventArgs e) { string inputKey; bool capsLock = IsKeyLocked(Keys.CapsLock); // Check for capslock is on bool shift = e.Shift; // Check for Shift button was pressed if ((shift && !capsLock) || (!shift && capsLock))...

jQuery.html() being garbled in IE

javascript,jquery,internet-explorer,character-encoding,keycode

Character 8206, or \u200E, it the "left-to-right mark" character. It is used primarily in bidirectional text to indicate that "this part" should be left-to-right. Depending on the locale, IE may be inserting these marks to ensure that the date is rendered correctly. For instance, if you are on a computer...

How to print key character code in OSX?

osx,keycode

There was an utility called keycode on the store...

Using keypress to target two different keys within same expression?

javascript,calculator,keypress,keycode

if ((isShift == true && event.keyCode == 56) || event.keyCode == 106 || event.keyCode == 88) {calc.passMethod('multiply');} ...

What is the char represented by keycode (15) c#?

c#,sql,string,keycode

Looking at the string you have in your question in the HTML source it is written as a&rlm;. A quick google shows that rlm is the left to right mark which is unicode U+200F (http://en.wikipedia.org/wiki/Right-to-left_mark). Combine this with other people's observation that casting to byte leaves only the final byte...

jQuery syntax for if checking if class along with keydown

javascript,jquery,if-statement,syntax,keycode

Here is a working JSFiddle You can check for the class within your keypress function: $(function() { $(window).keypress(function(event) { if ((event.keyCode == 13) && ($('div').hasClass('this'))) { $('#thing').addClass('that'); } }); }); You may want to change the generic div to check whether a certain div has the class by its id...

On click, press enter to textbox

javascript,input,keycode

This is an example if you want to add the value of the subcategory element to a textarea. You can use the newline character \n instead of the HTML element <br> $('#subcategory1').on('change', function() { $('#properties').val($('#properties').val() + "\n" + $(this).val()); }); HTML: <textarea name="properties" id="properties"></textarea> ...

AngularJS Keypress Keycode Directive

javascript,angularjs,keypress,keycode

you are targeting the wrong attribute value on your $eval call. Forked and fixed - http://plnkr.co/edit/0fsKoHAAgTvl4l2z8SfJ?p=preview should be: scope.$eval(attrs.customKeypress);...

Is Shift the only key that can change the value of keyCode?

javascript,keycode

The assumption is wrong. You see, the keydown event is fired whenever you press a key. The keypress event is fired only when said key outputs a printable character. That being said, pressing a key between a and z, for example "a" will generate: keydown with keyCode 65 (A) keypress...