All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rwt.event.KeyEvent.js Maven / Gradle / Ivy

/*******************************************************************************
 * Copyright (c) 2004, 2013 1&1 Internet AG, Germany, http://www.1und1.de,
 *                          EclipseSource and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    1&1 Internet AG and others - original API and implementation
 *    EclipseSource - adaptation for the Eclipse Remote Application Platform
 ******************************************************************************/

/**
 * A key event instance contains all data for each occured key event
 */
rwt.qx.Class.define("rwt.event.KeyEvent",
{
  extend : rwt.event.DomEvent,

  /**
   * @param vType {String} event type (keydown, keypress, keyup)
   * @param vDomEvent {Element} DOM event object
   * @param vDomTarget {Element} target element of the DOM event
   * @param vTarget
   * @param vOriginalTarget
   * @param vKeyCode {Integer} emulated key code for compatibility with older qoodoo applications
   * @param vCharCode {Integer} char code from the "keypress" event
   * @param vKeyIdentifier {String} the key identifier
   */
  construct : function(vType, vDomEvent, vDomTarget, vTarget, vOriginalTarget, vKeyCode, vCharCode, vKeyIdentifier)
  {
    this.base(arguments, vType, vDomEvent, vDomTarget, vTarget, vOriginalTarget);

    this._keyCode = vKeyCode;
    this.setCharCode(vCharCode);
    this.setKeyIdentifier(vKeyIdentifier);
  },




  /*
  *****************************************************************************
     STATICS
  *****************************************************************************
  */

  statics :
  {
    /**
     * Mapping of the old key identifiers to the key codes
     * @deprecated
     */
    keys :
    {
      esc             : 27,
      enter           : 13,
      tab             : 9,
      space           : 32,
      up              : 38,
      down            : 40,
      left            : 37,
      right           : 39,
      shift           : 16,
      ctrl            : 17,
      alt             : 18,
      f1              : 112,
      f2              : 113,
      f3              : 114,
      f4              : 115,
      f5              : 116,
      f6              : 117,
      f7              : 118,
      f8              : 119,
      f9              : 120,
      f10             : 121,
      f11             : 122,
      f12             : 123,
      print           : 124,
      del             : 46,
      backspace       : 8,
      insert          : 45,
      home            : 36,
      end             : 35,
      pageup          : 33,
      pagedown        : 34,
      numlock         : 144,
      numpad_0        : 96,
      numpad_1        : 97,
      numpad_2        : 98,
      numpad_3        : 99,
      numpad_4        : 100,
      numpad_5        : 101,
      numpad_6        : 102,
      numpad_7        : 103,
      numpad_8        : 104,
      numpad_9        : 105,
      numpad_divide   : 111,
      numpad_multiply : 106,
      numpad_minus    : 109,
      numpad_plus     : 107
    },

    /**
     * Mapping of the key codes to the key identifiers
     */
    codes : {}
  },




  /*
  *****************************************************************************
     PROPERTIES
  *****************************************************************************
  */

  properties :
  {

    /**
     * Unicode number of the pressed character.
     */
    charCode :
    {
      _fast       : true,
      setOnlyOnce : true,
      noCompute   : true
    },


    /**
     * Identifier of the pressed key. This property is modeled after the KeyboardEvent.keyIdentifier property
     * of the W3C DOM 3 event specification (http://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/events.html#Events-KeyboardEvent-keyIdentifier).
     *
     * Printable keys are represented by a unicode string, non-printable keys have one of the following
     * values:
     * 
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
BackspaceThe Backspace (Back) key.
TabThe Horizontal Tabulation (Tab) key.
SpaceThe Space (Spacebar) key.
EnterThe Enter key. Note: This key identifier is also used for the Return (Macintosh numpad) key.
ShiftThe Shift key.
ControlThe Control (Ctrl) key.
AltThe Alt (Menu) key.
CapsLockThe CapsLock key
MetaThe Meta key. (Apple Meta and Windows key)
EscapeThe Escape (Esc) key.
LeftThe Left Arrow key.
UpThe Up Arrow key.
RightThe Right Arrow key.
DownThe Down Arrow key.
PageUpThe Page Up key.
PageDownThe Page Down (Next) key.
EndThe End key.
HomeThe Home key.
InsertThe Insert (Ins) key. (Does not fire in Opera/Win)
DeleteThe Delete (Del) Key.
F1The F1 key.
F2The F2 key.
F3The F3 key.
F4The F4 key.
F5The F5 key.
F6The F6 key.
F7The F7 key.
F8The F8 key.
F9The F9 key.
F10The F10 key.
F11The F11 key.
F12The F12 key.
NumLockThe Num Lock key.
PrintScreenThe Print Screen (PrintScrn, SnapShot) key.
ScrollThe scroll lock key
PauseThe pause/break key
WinThe Windows Logo key
AppsThe Application key (Windows Context Menu)
*/ keyIdentifier : { _fast : true, setOnlyOnce : true, noCompute : true } }, /* ***************************************************************************** MEMBERS ***************************************************************************** */ members : { /** * Legacy keycode * @deprecated Will be removed with qooxdoo 0.7 */ getKeyCode : function() { return this._keyCode; } }, /* ***************************************************************************** DEFER ***************************************************************************** */ defer : function(statics) { // create dynamic codes copy for (var i in statics.keys) { statics.codes[statics.keys[i]] = i; } } });




© 2015 - 2025 Weber Informatics LLC | Privacy Policy