10 examples of 'search box enter key javascript' in JavaScript

Every line of 'search box enter key javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
297function bindEnterKeyForSearchBox() {
298 $('#searchQuery').keypress((e) => {
299 // 13 is the Unicode character code for enter key
300 if (e.keyCode === 13) {
301 $('#search').click();
302 }
303 });
304}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

137function promptKey(key){
138 // Handling all key types
139 if(key.length==1) $("#"+key.toLowerCase()).toggleClass("prompt");
140 else {
141 if(key.toLowerCase()=='ctrl'||key.toLowerCase()=='control')
142 $("#control").toggleClass("prompt");
143 if(key.toLowerCase()=='command' || key.toLowerCase()=='cmd'|| key.toLowerCase()=="meta")
144 $("#metaleft").toggleClass("prompt");
145 if(key.toLowerCase()=='fn')
146 $("#fnc").toggleClass("prompt");
147 if(key.toLowerCase()=='alt')
148 $("#optionleft").toggleClass("prompt");
149 if(key.toLowerCase()=='shift')
150 $("#shiftleft").toggleClass("prompt");
151 if(key.toLowerCase()=='esc')
152 $("#escape").toggleClass("prompt");
153 if(key.toLowerCase()=='space bar')
154 $("#space").toggleClass("prompt");
155 if(key.toLowerCase()=='tab')
156 $("#tab").toggleClass("prompt");
157 if(key.toLowerCase()=='tilde(~)')
158 $("#tilde").toggleClass("prompt");
159 if(key.toLowerCase()=='comma(,)')
160 $("#comma").toggleClass("prompt");
161 if(key.toLowerCase()=='underscore(_)')
162 $("#minus").toggleClass("prompt");
163 }
164}
87function onKeyUpSearch(searchInputEl) {
88 var text = searchInputEl.value.toLowerCase();
89 var testDivEl = searchInputEl.closest(".testDiv");
90 var ulEl = testDivEl.querySelector("#generatedUl");
91 var liList = ulEl.getElementsByTagName("li");
92 var displayIndex = 0;
93 for (i = 0; i < liList.length; i++) {
94 if (!liList[i].innerHTML.toLowerCase().includes(text)) {
95 liList[i].style.display = "none";
96 liList[i].dataset.displayIndex = -1;
97 } else {
98 liList[i].style.display = "";
99 liList[i].dataset.displayIndex = displayIndex;
100 displayIndex++;
101 }
102 }
103 ulEl.dataset.displayElements = displayIndex;
104 if (curFocusedLi != null && curFocusedLi.dataset.displayIndex == -1) {
105 clearFocusLi(curFocusedLi);
106 curFocusedLi = null;
107 ulEl.scrollTop = 0;
108 }
109};
142function onSearchKey(e) {
143 var target = e.target;
144
145 if (target.test('input,select,textarea')
146 || target.get('isContentEditable')) {
147 return;
148 }
149
150 e.preventDefault();
151
152 inputNode.focus();
153 focusManager.refresh();
154}
3$("#inputMass").on("keydown",function search(e) {
4 if(e.keyCode === 13){
5
6 var val = $(this).val();
7 user.velocity = val;
8 // ball._physijs.mass = val;
9 // scene.execute( 'updateMass', { id: ball._physijs.id, mass: val } );
10 // console.log('ballMass', ball._physijs.mass);
11 }
12});
78handleKeyUp(e) {
79 if (e.keyCode === 13) {
80 this.searchClicked();
81 }
82}
40handleSearchKey(event) {
41 this.setState({
42 keyword: event.target.value
43 })
44}
9handleKeyPress(e) {
10 this.props.onChange({searchTerm: e.target.value});
11}
93handleSearchInput(e) {
94 this.setState({
95 query: e.target.value.trim()
96 });
97}
16handleKeyPress() {
17 //the startSearch function from App is being used from the AddMessage component via props
18 this.props.startSearch( this.state.input)//<---is coming from the the state set above in the this.state = { input: ""}
19 this.setState({
20 input: ''
21 })
22}

Related snippets