Please correct me this text, I am using android browser so i need the spacebar to act as physical spacebar with an API, This physical spacebar is actually itself acting as Enter (to select from list) and adding "space" to the text. its like an interactive text correction
var textFieldEntry = document.querySelectorAll('textarea.field-input');
$(document).on('keyup', function(e){
if (e.key == 'Space' || e.keyup == 229) {
console.log("space pressed");
console.log("e.target", e.target);
console.log("textFieldEntry", textFieldEntry);
if (e.target !== textFieldEntry) {
e.preventDefault();
e.target.click();
};
}
});
Answer from Mchich on Stack Overflow Top answer 1 of 2
2
Please correct me this text, I am using android browser so i need the spacebar to act as physical spacebar with an API, This physical spacebar is actually itself acting as Enter (to select from list) and adding "space" to the text. its like an interactive text correction
var textFieldEntry = document.querySelectorAll('textarea.field-input');
$(document).on('keyup', function(e){
if (e.key == 'Space' || e.keyup == 229) {
console.log("space pressed");
console.log("e.target", e.target);
console.log("textFieldEntry", textFieldEntry);
if (e.target !== textFieldEntry) {
e.preventDefault();
e.target.click();
};
}
});
2 of 2
0
not an answer, designed to show OP why his function doesn't work as intended and will be removed
var textFieldEntry = document.querySelectorAll('input.field-input');
$(document).on('keydown', function(e){
if (e.key == 'Space' || e.keyCode == 32) {
console.log("space pressed");
console.log("e.target", e.target);
console.log("textFieldEntry", textFieldEntry);
if (e.target !== textFieldEntry) {
e.preventDefault();
e.target.click();
};
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input class="field-input"/>
<input class="field-input"/>
<input class="field-input"/>
Toptal
toptal.com › developers › keycode › space
JavaScript Key Code for Space | Toptal®
{ "key": " ", "keyCode": 32, "which": 32, "code": "Space", "location": 0, "description": "spacebar", "path": "/space" }
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › KeyboardEvent › keyCode
KeyboardEvent: keyCode property - Web APIs | MDN
The deprecated KeyboardEvent.keyCode read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key.
ForeUI
foreui.com › articles › Key_Code_Table.htm
Key Code Table
Provide the list of key code that can be used in condition express.
Longwin
blogs.longwin.com.tw › lifetype › key_codes.html
Key Codes
Javascript - Web Experts
W3C
lists.w3.org › Archives › Public › www-dom › 2010JulSep › att-0182 › keyCode-spec.html
keyCode property of key events
If the implementation supports a 'conflated model', set keyCode to the Unicode code point of the character being entered.
JavaScripter
javascripter.net › faq › keycodes.htm
JavaScript keydown/keyup events: key codes
Key codes of keydown and keyup events JavaScript FAQ | Keyboard & Mouse Events FAQ · Question: Are the keyCode values of keydown/keyup events standardized across browsers
asawicki.info
asawicki.info › nosense › doc › devices › keyboard › key_codes.html
Key codes
32 - Space · 33 - Page Up · 34 - Page Down · 35 - End · 36 - Home · 37 - Left arrow · 38 - Up arrow · 39 - Right arrow · 40 - Down arrow · 44 - Print Screen · 45 - Insert · 46 - Delete · 48 - 0 · 49 - 1 · 50 - 2 · 51 - 3 · 52 - 4 · 53 - 5 · 54 - 6 · 55 - 7 ·
Toptal
toptal.com › developers › keycode
JavaScript Key Code Event Tool | Toptal®
KeyCode.Info allows users to press any key and instantly get the JavaScript Key or Key Code KeyboardEvent. Check out the Tool and Event List.
GCCTech
gcctech.org › csc › javascript › javascript_keycodes.htm
JavaScript Keycodes - GC Computer Technology
Here is a sample program using the keycodes You can view it's source to the the actual coding
GitHub
github.com › the-via › app › pull › 44
Allow 32 total User Defined Custom Keycodes by mrnoisytiger · Pull Request #44 · the-via/app
The previous limit of 16 custom user keycodes was a little bit limiting. This change increases the allowable total number of user defined custom keycodes up to 32. I, personally, think 32 is enough...
Author the-via
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › system.windows.forms.keys
Keys Enum (System.Windows.Forms) | Microsoft Learn
// Boolean flag used to determine when a character other than a number is entered. private: bool nonNumberEntered; // Handle the KeyDown event to determine the type of character entered into the control. void textBox1_KeyDown( Object^ /*sender*/, System::Windows::Forms::KeyEventArgs^ e ) { // Initialize the flag to false. nonNumberEntered = false; // Determine whether the keystroke is a number from the top of the keyboard. if ( e->KeyCode < Keys::D0 || e->KeyCode > Keys::D9 ) { // Determine whether the keystroke is a number from the keypad.
O'Reilly
oreilly.com › library › view › javascript-dhtml › 9780596514082 › apb.html
B. Keyboard Key Code Values - JavaScript & DHTML Cookbook, 2nd Edition [Book]
August 8, 2007 - Appendix B. Keyboard Key Code ValuesKey codes are numeric values that correspond to physical keys on the keyboard but do not necessarily correspond to a particular... - Selection from JavaScript & DHTML Cookbook, 2nd Edition [Book]
Author Danny Goodman
Published 2007
Pages 603