2011-05-08 08:43:52 -04:00
|
|
|
/*
|
2013-01-28 21:03:27 -05:00
|
|
|
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
2011-05-08 08:43:52 -04:00
|
|
|
* http://paperjs.org/
|
2011-06-30 06:01:51 -04:00
|
|
|
*
|
2014-01-03 19:47:16 -05:00
|
|
|
* Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey
|
|
|
|
* http://scratchdisk.com/ & http://jonathanpuckey.com/
|
2011-06-30 06:01:51 -04:00
|
|
|
*
|
2011-07-01 06:17:45 -04:00
|
|
|
* Distributed under the MIT license. See LICENSE file for details.
|
|
|
|
*
|
2011-05-08 08:43:52 -04:00
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2011-06-22 18:56:05 -04:00
|
|
|
/**
|
|
|
|
* @name KeyEvent
|
2011-06-30 06:01:51 -04:00
|
|
|
*
|
2012-12-23 10:01:53 -05:00
|
|
|
* @class The KeyEvent object is received by the {@link Tool}'s keyboard
|
|
|
|
* handlers {@link Tool#onKeyDown}, {@link Tool#onKeyUp}. The KeyEvent object is
|
|
|
|
* the only parameter passed to these functions and contains information about
|
|
|
|
* the keyboard event.
|
2011-06-22 18:56:05 -04:00
|
|
|
*
|
|
|
|
* @extends Event
|
|
|
|
*/
|
2013-05-27 15:48:58 -04:00
|
|
|
var KeyEvent = Event.extend(/** @lends KeyEvent# */{
|
2013-06-23 23:18:32 -04:00
|
|
|
_class: 'KeyEvent',
|
|
|
|
|
2013-05-27 15:48:58 -04:00
|
|
|
initialize: function KeyEvent(down, key, character, event) {
|
2013-05-27 12:11:50 -04:00
|
|
|
Event.call(this, event);
|
2011-11-16 16:54:03 -05:00
|
|
|
this.type = down ? 'keydown' : 'keyup';
|
|
|
|
this.key = key;
|
|
|
|
this.character = character;
|
|
|
|
},
|
2011-05-23 13:56:18 -04:00
|
|
|
|
2011-11-16 16:54:03 -05:00
|
|
|
/**
|
|
|
|
* The type of key event.
|
|
|
|
*
|
|
|
|
* @name KeyEvent#type
|
|
|
|
* @type String('keydown', 'keyup')
|
|
|
|
*/
|
2011-05-23 13:56:18 -04:00
|
|
|
|
2011-11-16 16:54:03 -05:00
|
|
|
/**
|
|
|
|
* The string character of the key that caused this key event.
|
|
|
|
*
|
|
|
|
* @name KeyEvent#character
|
|
|
|
* @type String
|
|
|
|
*/
|
2011-05-23 13:56:18 -04:00
|
|
|
|
2011-11-16 16:54:03 -05:00
|
|
|
/**
|
|
|
|
* The key that caused this key event.
|
|
|
|
*
|
|
|
|
* @name KeyEvent#key
|
|
|
|
* @type String
|
|
|
|
*/
|
2011-05-23 13:56:18 -04:00
|
|
|
|
2011-11-16 16:54:03 -05:00
|
|
|
/**
|
2013-08-23 22:45:28 -04:00
|
|
|
* @return {String} a string representation of the key event
|
2011-11-16 16:54:03 -05:00
|
|
|
*/
|
|
|
|
toString: function() {
|
2012-12-08 22:57:04 -05:00
|
|
|
return "{ type: '" + this.type
|
|
|
|
+ "', key: '" + this.key
|
|
|
|
+ "', character: '" + this.character
|
|
|
|
+ "', modifiers: " + this.getModifiers()
|
|
|
|
+ " }";
|
2011-11-16 16:54:03 -05:00
|
|
|
}
|
2011-05-08 08:43:52 -04:00
|
|
|
});
|