10 examples of 'tab key press event in javascript' in JavaScript

Every line of 'tab key press event in 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
227function onTabSwitchKey(e) {
228 var currentTabIndex = tabs.selected.index;
229
230 if (!(e.ctrlKey || e.metaKey)) {
231 return;
232 }
233
234 e.preventDefault();
235
236 switch (e.keyCode) {
237 case 37: // left arrow
238 if (currentTabIndex > 0) {
239 tabview.selectChild(currentTabIndex - 1);
240 inputNode.focus();
241 }
242 break;
243
244 case 39: // right arrow
245 if (currentTabIndex < (Y.Object.size(tabs) - 2)) {
246 tabview.selectChild(currentTabIndex + 1);
247 inputNode.focus();
248 }
249 break;
250 }
251}
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

33function onClickHandler(info, tab) {
34 var code;
35 if (info.menuItemId == 'toggle')
36 code = '$("#stopBtn").click();';
37 else if (info.menuItemId == 'clear') {
38 code = 'if(localStorage.coopraid == ' + tab.id + ') localStorage.removeItem("coopraid");';
39 code += 'if(localStorage.assist == ' + tab.id + ') localStorage.removeItem("assist");';
40 code += 'if(localStorage.autoEvent == ' + tab.id + ') localStorage.removeItem("autoEvent");';
41 code += 'if(localStorage.autoExtraEvent == ' + tab.id + ') localStorage.removeItem("autoExtraEvent");';
42 code += 'if(localStorage.autoExtra == ' + tab.id + ') localStorage.removeItem("autoExtra");';
43 code += 'if(localStorage.magna == ' + tab.id + ') localStorage.removeItem("magna");';
44 } else if (info.menuItemId == 'clearAll') {
45 code = 'localStorage.removeItem("coopraid");';
46 code += 'localStorage.removeItem("assist");';
47 code += 'localStorage.removeItem("autoEvent");';
48 code += 'localStorage.removeItem("autoExtraEvent");';
49 code += 'localStorage.removeItem("autoExtra");';
50 code += 'localStorage.removeItem("magna");';
51 } else {
52 code = 'if(localStorage.coopraid == ' + tab.id + ') localStorage.removeItem("coopraid");';
53 code += 'if(localStorage.assist == ' + tab.id + ') localStorage.removeItem("assist");';
54 code += 'if(localStorage.autoEvent == ' + tab.id + ') localStorage.removeItem("autoEvent");';
55 code += 'if(localStorage.autoExtraEvent == ' + tab.id + ') localStorage.removeItem("autoExtraEvent");';
56 code += 'if(localStorage.autoExtra == ' + tab.id + ') localStorage.removeItem("autoExtra");';
57 code += 'if(localStorage.magna == ' + tab.id + ') localStorage.removeItem("magna");';
58 code += 'localStorage.setItem(\'' + info.menuItemId + '\', ' + tab.id + ')';
59 }
60 chrome.tabs.executeScript(tab.id, {
61 code: code
62 });
63}
30handleKeyDown(e) {
31 const { atpManager } = this.context;
32 switch (e.key) {
33 case keys.LEFT:
34 case keys.UP:
35 e.preventDefault();
36 atpManager.changePrev();
37 break;
38 case keys.RIGHT:
39 case keys.DOWN:
40 e.preventDefault();
41 atpManager.changeNext();
42 break;
43 default:
44 }
45}
75value: function _onClickTab(event) {
76 var onChange = this.props.onChange;
77
78 if (event) {
79 event.preventDefault();
80 }
81 onChange();
82}
59function checkEmulatedTabKeyDown(event) {
60 if (!isEmulatedTabkey(event)) {
61 return;
62 }
63
64 var $target = $(event.target),
65 wasDone = null;
66
67 if ($target.is(disablePlusAsTab)
68 || $target.parents(disablePlusAsTab).length > 0
69 || (!$target.is(enablePlusAsTab)
70 && $target.parents(enablePlusAsTab).length === 0)) {
71 return;
72 }
73
74 wasDone = performEmulatedTabbing(true, event.shiftKey, $target);
75
76 if (wasDone) {
77 event.preventDefault();
78 event.stopPropagation();
79 event.stopImmediatePropagation();
80
81 return false;
82 }
83
84 return;
85}
69_onTabButton(ev) {
70 const $button = $(ev.target);
71 this._activateTabByButton($button);
72 this.trigger('itemClick', $button.text());
73}
380function trapTabKey(node, event) {
381 var focusableChildren = getFocusableChildren(node);
382 var focusedItemIndex = focusableChildren.indexOf(document.activeElement);
383
384 // If the SHIFT key is being pressed while tabbing (moving backwards) and
385 // the currently focused item is the first one, move the focus to the last
386 // focusable item from the dialog element
387 if (event.shiftKey && focusedItemIndex === 0) {
388 focusableChildren[focusableChildren.length - 1].focus();
389 event.preventDefault();
390 // If the SHIFT key is not being pressed (moving forwards) and the currently
391 // focused item is the last one, move the focus to the first focusable item
392 // from the dialog element
393 } else if (!event.shiftKey && focusedItemIndex === focusableChildren.length - 1) {
394 focusableChildren[0].focus();
395 event.preventDefault();
396 }
397}
144_onKeyPressEvent(widget, event) {
145 let toolbar = this._embed.getMainToolbar();
146 return toolbar.handleEvent(event);
147}
284protected onTabEvent(event: KeyboardEvent, ch: number, line: number): void {
285 let editor = this.editor;
286 let editorModel = editor.model;
287
288 // If there is a text selection, no completion requests should be emitted.
289 if (!editorModel.selections.isEmpty) {
290 return;
291 }
292
293 let currentValue = editorModel.value;
294 let currentLine = currentValue.split('\n')[line];
295 let chHeight = editor.lineHeight;
296 let chWidth = editor.charWidth;
297 let coords = editor.getCoords({
298 line: line,
299 column: ch
300 });
301 let position = editorModel.getOffsetAt({
302 line: line,
303 column: ch
304 });
305
306 // A completion request signal should only be emitted if the current
307 // character or a preceding character is not whitespace.
308 //
309 // Otherwise, the default tab action of creating a tab character should be
310 // allowed to propagate.
311 if (!currentLine.substring(0, ch).match(/\S/)) {
312 return;
313 }
314
315 event.preventDefault();
316 event.stopPropagation();
317 event.stopImmediatePropagation();
318
319 let data = {
320 line, ch, chHeight, chWidth, coords, position, currentValue
321 };
322 this.completionRequested.emit(data as ICompletionRequest);
323}
56private onKeyPress(e: React.KeyboardEvent<HTMLInputElement>) {
57 if (e.key === 'Enter') {
58 this.sendMessage();
59 }
60}

Related snippets