forked from MattStultz/extrusiongen
-
Notifications
You must be signed in to change notification settings - Fork 1
/
IKRS.KeyEvent.js~
44 lines (33 loc) · 948 Bytes
/
IKRS.KeyEvent.js~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* This is a wrapper class for javascript key events.
*
* Native javascript events are very simple and not comfortable
* to use.
*
* This adds some extra features to the event.
*
* @authos Ikaros Kappler
* @version 1.0.0
* @date 2014-08-11
**/
IKRS.KeyEvent = function( keyEvent ) {
IKRS.Object.call( this );
this.keyEvent = keyEvent;
};
IKRS.KeyEvent.prototype = new IKRS.Object();
IKRS.KeyEvent.prototype.constructor = IKRS.KeyEvent;
IKRS.KeyEvent.prototype.getKeyCode = function() {
return this.keyEvent.keyCode;
};
IKRS.KeyEvent.prototype.isShiftKey = function() {
return this.keyEvent.keyCode == 16;
};
IKRS.KeyEvent.prototype.isControlKey = function() {
return this.keyEvent.keyCode == 17;
};
IKRS.KeyEvent.prototype.isCharacterKey = function( character ) {
if( character.length == 0 )
return false;
else
return this.keyEvent.keyCode == character.charCodeAt(0);
};