remove mismatched html tags
[fnpeditor.git] / src / editor / modules / documentCanvas / canvas / keyEvent.js
1 define(function(require) {
2     
3 'use strict';
4
5 var _ = require('libs/underscore'),
6     keyboard = require('modules/documentCanvas/canvas/keyboard');
7
8 var KEYS = keyboard.KEYS;
9
10 var KeyEvent = function(params) {
11     this.key = params.key;
12     this.ctrlKey = params.ctrlKey;
13     this._nativeEvent = params._nativeEvent;
14 };
15
16 _.extend(KeyEvent.prototype, KEYS, {
17     forKey: function(k) {
18         return k === this.key;
19     },
20     preventDefault: function() {
21         if(this._nativeEvent) {
22             this._nativeEvent.preventDefault();
23         }
24     }
25 });
26
27 return {
28     fromParams: function(params) {
29         return new KeyEvent(params);
30     },
31     fromNativeEvent: function(e) {
32         return this.fromParams({
33             key: e.which,
34             ctrlKey: e.ctrlKey,
35             _nativeEvent: e
36         });
37     }
38 };
39
40 });