10 examples of 'code for enter key' in JavaScript

Every line of 'code for enter key' 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
137key(kCode){ return (this.keyState[kCode] == true); }
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

42function lookup(key: FlexibleKey): string {
43 switch (key) {
44 case FlexibleKey.ENTER:
45 return 'ENTER';
46 case FlexibleKey.ESCAPE:
47 return 'ESCAPE';
48 case FlexibleKey.TAB:
49 return 'TAB';
50 }
51}
87function enterKey(browser)
88{
89 browser.and(keyPress(13));
90};
25onKey(e: KeyboardEvent): void {
26 this.data = e.key;
27}
58_getKeyCode(e) {
59 const code = KeyboardUtil.getKeycode(e);
60 if (code !== 'Unidentified') {
61 return code;
62 }
63
64 // Unstable, but we don't have anything else to go on
65 // (don't use it for 'keypress' events thought since
66 // WebKit sets it to the same as charCode)
67 if (e.keyCode && (e.type !== 'keypress')) {
68 // 229 is used for composition events
69 if (e.keyCode !== 229) {
70 return 'Platform' + e.keyCode;
71 }
72 }
73
74 // A precursor to the final DOM3 standard. Unfortunately it
75 // is not layout independent, so it is as bad as using keyCode
76 if (e.keyIdentifier) {
77 // Non-character key?
78 if (e.keyIdentifier.substr(0, 2) !== 'U+') {
79 return e.keyIdentifier;
80 }
81
82 const codepoint = parseInt(e.keyIdentifier.substr(2), 16);
83 const char = String.fromCharCode(codepoint).toUpperCase();
84
85 return 'Platform' + char.charCodeAt();
86 }
87
88 return 'Unidentified';
89}
86function keyDown(e) {
87 if (e.keyCode == 87 || e.keyCode == 38) {//Arrow Up
88 this.keys.up = 1;
89
90 }else if (e.keyCode == 83 || e.keyCode == 40) {//Arrow Down
91 this.keys.down = 1;
92
93 } else if (e.keyCode == 65 || e.keyCode == 37) {//Arrow Left
94 this.keys.left = 1;
95
96 } else if (e.keyCode == 68 || e.keyCode == 39) {//Arrow Right
97 this.keys.right = 1;
98 }
99}
26_onKeyPress(event) {
27 this._forwardEvent('keypress', event);
28 // Handle: Ctrl + C
29 if (event && event.ctrlKey && event.key === 'c') {
30 process.exit(0);
31 }
32}
685function checkKey(e) {
686 if (config.escapeDeactivates !== false && isEscapeEvent(e)) {
687 e.preventDefault();
688 deactivate();
689 return;
690 }
691 if (isTabEvent(e)) {
692 checkTab(e);
693 return;
694 }
695}
187function typeKey(e) {
188 // get the key
189 var key = event.keyCode || event.which;
190 var keySel = module.sel.selectAll(".key").filter(function(d) { return d.key === String.fromCharCode(key) });
191 if(keySel.empty()) keySel = module.sel.selectAll(".key").filter(function(d) { return d.keycode === key });
192 var scanType = (d3.event.type == "keydown" || d3.event.type == "keypress" ? "make" : "break");
193 drawKey(keySel, scanType);
194}
32function handlekeyboard(key, e)
33{
34 if(!AjaxLife.Initialised || !AjaxLife.Network.Connected || !enabled) return;
35 AjaxLife.Debug("Keyboard: Got keycode "+key);
36 e.preventDefault();
37 switch(key)
38 {
39 case 72: // h
40 if(e.shiftKey)
41 {
42 if(e.altKey)
43 {
44 AjaxLife.SpatialChat.systemmessage("hippos!");
45 }
46 else
47 {
48 AjaxLife.Map.GoHome();
49 }
50 }
51 else
52 {
53 AjaxLife.SpatialChat.toggle();
54 }
55 break;
56 case 73: // i
57 AjaxLife.Inventory.toggle();
58 break;
59 case 70: // f
60 AjaxLife.Search.toggle();
61 break;
62 case 77: // m
63 AjaxLife.Map.toggle();
64 break;
65 case 81: // q
66 // This is duplicated in AjaxLife.Toolbar.js. Should move these both somewhere nice - but where?
67 // If this is no longer duplicated in AjaxLife.Toolbar.js, it's either wrong, broken or both.
68 AjaxLife.Widgets.Confirm(_("Toolbar.LogoutTitle"),_("Toolbar.LogoutPrompt"), function(btn) {
69 if(btn == 'yes')
70 {
71 AjaxLife.Network.logout();
72 }
73 });
74 break;
75 case 49: // 1
76 if(!Prototype.Browser.IE) AjaxLife.Stats.toggle(); // Should we stop checking for IE and check for something else?
77 break;
78 case 83: // s
79 AjaxLife.Sound.Toggle();
80 break;
81 }
82}

Related snippets