Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
5 changes: 3 additions & 2 deletions src/document/DocumentCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ define(function (require, exports, module) {
Dialogs = require("widgets/Dialogs"),
Strings = require("strings"),
PreferencesManager = require("preferences/PreferencesManager"),
PerfUtils = require("utils/PerfUtils");
PerfUtils = require("utils/PerfUtils"),
KeyEvent = require("utils/KeyEvent");

/**
* Handlers for commands related to document handling (opening, saving, etc.)
Expand Down Expand Up @@ -746,7 +747,7 @@ define(function (require, exports, module) {
* @param {jQueryEvent} event Key-up event
*/
function detectDocumentNavEnd(event) {
if (event.keyCode === 17) { // Ctrl key
if (event.keyCode === KeyEvent.DOM_VK_CONTROL) { // Ctrl key
DocumentManager.finalizeDocumentNavigation();

_addedNavKeyHandler = false;
Expand Down
5 changes: 3 additions & 2 deletions src/editor/InlineWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ define(function (require, exports, module) {
"use strict";

// Load dependent modules
var EditorManager = require("editor/EditorManager");
var EditorManager = require("editor/EditorManager"),
KeyEvent = require("utils/KeyEvent");

/**
* @constructor
Expand All @@ -45,7 +46,7 @@ define(function (require, exports, module) {
.append("<div class='shadow bottom' />");

this.$htmlContent.on("keydown", function (e) {
if (e.keyCode === 27) {
if (e.keyCode === KeyEvent.DOM_VK_ESCAPE) {
self.close();
e.stopImmediatePropagation();
}
Expand Down
6 changes: 4 additions & 2 deletions src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ define(function (require, exports, module) {
PerfUtils = require("utils/PerfUtils"),
ViewUtils = require("utils/ViewUtils"),
FileUtils = require("file/FileUtils"),
Urls = require("i18n!nls/urls");
Urls = require("i18n!nls/urls"),
KeyEvent = require("utils/KeyEvent");

/**
* @private
Expand Down Expand Up @@ -926,7 +927,8 @@ define(function (require, exports, module) {

$renameInput.on("keydown", function (event) {
// Listen for escape key on keydown, so we can remove the node in the create.jstree handler above
if (event.keyCode === 27) {
if (event.keyCode === KeyEvent.DOM_VK_ESCAPE) {

escapeKeyPressed = true;
}
});
Expand Down
8 changes: 5 additions & 3 deletions src/search/FindInFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ define(function (require, exports, module) {
StringUtils = require("utils/StringUtils"),
DocumentManager = require("document/DocumentManager"),
EditorManager = require("editor/EditorManager"),
FileIndexManager = require("project/FileIndexManager");
FileIndexManager = require("project/FileIndexManager"),
KeyEvent = require("utils/KeyEvent");


var FIND_IN_FILES_MAX = 100;

Expand Down Expand Up @@ -108,13 +110,13 @@ define(function (require, exports, module) {
$searchField.get(0).select();

$searchField.bind("keydown", function (event) {
if (event.keyCode === 13 || event.keyCode === 27) { // Enter/Return key or Esc key
if (event.keyCode === KeyEvent.DOM_VK_RETURN || event.keyCode === KeyEvent.DOM_VK_ESCAPE) { // Enter/Return key or Esc key
event.stopPropagation();
event.preventDefault();

var query = $searchField.val();

if (event.keyCode === 27) {
if (event.keyCode === KeyEvent.DOM_VK_ESCAPE) {
query = null;
}

Expand Down
149 changes: 149 additions & 0 deletions src/utils/KeyEvent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/*
* Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/


/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global define, $, window */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove $ and window

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still seeing both here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right not sure how it slipped out of the bad of submissions. It updated it now.


/**
* Utilities for working with Deferred, Promise, and other asynchronous processes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix comment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

*/
define({
DOM_VK_CANCEL: 3,
DOM_VK_HELP: 6,
DOM_VK_BACK_SPACE: 8,
DOM_VK_TAB: 9,
DOM_VK_CLEAR: 12,
DOM_VK_RETURN: 13,
DOM_VK_ENTER: 14,
DOM_VK_SHIFT: 16,
DOM_VK_CONTROL: 17,
DOM_VK_ALT: 18,
DOM_VK_PAUSE: 19,
DOM_VK_CAPS_LOCK: 20,
DOM_VK_ESCAPE: 27,
DOM_VK_SPACE: 32,
DOM_VK_PAGE_UP: 33,
DOM_VK_PAGE_DOWN: 34,
DOM_VK_END: 35,
DOM_VK_HOME: 36,
DOM_VK_LEFT: 37,
DOM_VK_UP: 38,
DOM_VK_RIGHT: 39,
DOM_VK_DOWN: 40,
DOM_VK_PRINTSCREEN: 44,
DOM_VK_INSERT: 45,
DOM_VK_DELETE: 46,
DOM_VK_0: 48,
DOM_VK_1: 49,
DOM_VK_2: 50,
DOM_VK_3: 51,
DOM_VK_4: 52,
DOM_VK_5: 53,
DOM_VK_6: 54,
DOM_VK_7: 55,
DOM_VK_8: 56,
DOM_VK_9: 57,
DOM_VK_A: 65,
DOM_VK_B: 66,
DOM_VK_C: 67,
DOM_VK_D: 68,
DOM_VK_E: 69,
DOM_VK_F: 70,
DOM_VK_G: 71,
DOM_VK_H: 72,
DOM_VK_I: 73,
DOM_VK_J: 74,
DOM_VK_K: 75,
DOM_VK_L: 76,
DOM_VK_M: 77,
DOM_VK_N: 78,
DOM_VK_O: 79,
DOM_VK_P: 80,
DOM_VK_Q: 81,
DOM_VK_R: 82,
DOM_VK_S: 83,
DOM_VK_T: 84,
DOM_VK_U: 85,
DOM_VK_V: 86,
DOM_VK_W: 87,
DOM_VK_X: 88,
DOM_VK_Y: 89,
DOM_VK_Z: 90,
DOM_VK_CONTEXT_MENU: 93,
DOM_VK_NUMPAD0: 96,
DOM_VK_NUMPAD1: 97,
DOM_VK_NUMPAD2: 98,
DOM_VK_NUMPAD3: 99,
DOM_VK_NUMPAD4: 100,
DOM_VK_NUMPAD5: 101,
DOM_VK_NUMPAD6: 102,
DOM_VK_NUMPAD7: 103,
DOM_VK_NUMPAD8: 104,
DOM_VK_NUMPAD9: 105,
DOM_VK_MULTIPLY: 106,
DOM_VK_ADD: 107,
DOM_VK_SEPARATOR: 108,
DOM_VK_SUBTRACT: 109,
DOM_VK_DECIMAL: 110,
DOM_VK_DIVIDE: 111,
DOM_VK_F1: 112,
DOM_VK_F2: 113,
DOM_VK_F3: 114,
DOM_VK_F4: 115,
DOM_VK_F5: 116,
DOM_VK_F6: 117,
DOM_VK_F7: 118,
DOM_VK_F8: 119,
DOM_VK_F9: 120,
DOM_VK_F10: 121,
DOM_VK_F11: 122,
DOM_VK_F12: 123,
DOM_VK_F13: 124,
DOM_VK_F14: 125,
DOM_VK_F15: 126,
DOM_VK_F16: 127,
DOM_VK_F17: 128,
DOM_VK_F18: 129,
DOM_VK_F19: 130,
DOM_VK_F20: 131,
DOM_VK_F21: 132,
DOM_VK_F22: 133,
DOM_VK_F23: 134,
DOM_VK_F24: 135,
DOM_VK_NUM_LOCK: 144,
DOM_VK_SCROLL_LOCK: 145,
DOM_VK_SEMICOLON: 186,
DOM_VK_EQUALS: 187,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix indent

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why plural here? should be VK_EQUAL.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaced tab with spaces

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did think about that, but I looked it up. Turns out the original definition
per also defines the code as VK_EQUALS
http://www.javascripter.net/faq/keyeventconstantsfirefox.htm

Note - I redefined the code as the brackets uses 187.
KeyEvent.DOM_VK_EQUALS = 61

I assume you are OK with the code changes I applied vs the FF reference

quoted above?

J.

Raymond Lim [email protected] hat am 7. September 2012 um 20:47
geschrieben:

  • DOM_VK_F13: 124,
  • DOM_VK_F14: 125,
  • DOM_VK_F15: 126,
  • DOM_VK_F16: 127,
  • DOM_VK_F17: 128,
  • DOM_VK_F18: 129,
  • DOM_VK_F19: 130,
  • DOM_VK_F20: 131,
  • DOM_VK_F21: 132,
  • DOM_VK_F22: 133,
  • DOM_VK_F23: 134,
  • DOM_VK_F24: 135,
  • DOM_VK_NUM_LOCK: 144,
  • DOM_VK_SCROLL_LOCK: 145,
  • DOM_VK_SEMICOLON: 186,
  •    DOM_VK_EQUALS: 187,
    

Also, why plural here? should be VK_EQUAL.


Reply to this email directly or view it on GitHub:
https://github.com/adobe/brackets/pull/1583/files#r1557620

DOM_VK_COMMA: 188,
DOM_VK_DASH: 189,
DOM_VK_PERIOD: 190,
DOM_VK_SLASH: 191,
DOM_VK_BACK_QUOTE: 192,
DOM_VK_OPEN_BRACKET: 219,
DOM_VK_BACK_SLASH: 220,
DOM_VK_CLOSE_BRACKET: 221,
DOM_VK_QUOTE: 222,
DOM_VK_META: 224

});
5 changes: 3 additions & 2 deletions src/widgets/PopUpManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
define(function (require, exports, module) {
"use strict";

var EditorManager = require("editor/EditorManager");
var EditorManager = require("editor/EditorManager"),
KeyEvent = require("utils/KeyEvent");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix indent

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


var _popUps = [];

Expand Down Expand Up @@ -82,7 +83,7 @@ define(function (require, exports, module) {
}

function _keydownCaptureListener(keyEvent) {
if (keyEvent.keyCode !== 27) { // escape key
if (keyEvent.keyCode !== KeyEvent.DOM_VK_ESCAPE) { // escape key
return;
}

Expand Down
3 changes: 2 additions & 1 deletion test/spec/CodeHint-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ define(function (require, exports, module) {
var HTMLUtils = require("language/HTMLUtils"),
SpecRunnerUtils = require("spec/SpecRunnerUtils"),
Editor = require("editor/Editor").Editor,
KeyEvent = require("utils/KeyEvent"),
EditorManager, // loaded from brackets.test
CodeHintManager;

Expand Down Expand Up @@ -103,7 +104,7 @@ define(function (require, exports, module) {
// simulate Ctrl+space keystroke to invoke code hints menu
runs(function () {
var e = $.Event("keydown");
e.keyCode = 32; // spacebar key
e.keyCode = KeyEvent.DOM_VK_SPACE; // spacebar key
e.ctrlKey = true;

editor = EditorManager.getCurrentFullEditor();
Expand Down