move keyManager.js to KeyboardEventService.js

This commit is contained in:
Vince
2012-09-16 13:19:31 +02:00
parent 95bfc599e8
commit c4084cf9b6
2 changed files with 14 additions and 8 deletions

View File

@@ -69,7 +69,8 @@ $.namespace("pskl");
this.historyService = new pskl.service.HistoryService(frameSheet); this.historyService = new pskl.service.HistoryService(frameSheet);
this.historyService.init(); this.historyService.init();
this.keyManager = new pskl.KeyManager(); this.KeyboardEventService = new pskl.service.KeyboardEventService();
this.KeyboardEventService.init();
pskl.NotificationService.init(); pskl.NotificationService.init();
this.localStorageService = new pskl.service.LocalStorageService(frameSheet); this.localStorageService = new pskl.service.LocalStorageService(frameSheet);

View File

@@ -1,14 +1,12 @@
(function () { (function () {
var ns = $.namespace("pskl"); var ns = $.namespace("pskl");
ns.KeyManager = function () { ns.KeyboardEventService = function () {};
$(document.body).keydown($.proxy(this.onKeyUp_, this));
};
/** /**
* @private * @private
*/ */
ns.KeyManager.prototype.KeyboardActions_ = { ns.KeyboardEventService.prototype.KeyboardActions_ = {
"ctrl" : { "ctrl" : {
"z" : Events.UNDO, "z" : Events.UNDO,
@@ -22,7 +20,7 @@
/** /**
* @private * @private
*/ */
ns.KeyManager.prototype.CharCodeToKeyCodeMap_ = { ns.KeyboardEventService.prototype.CharCodeToKeyCodeMap_ = {
90 : "z", 90 : "z",
89 : "y", 89 : "y",
@@ -34,7 +32,7 @@
/** /**
* @private * @private
*/ */
ns.KeyManager.prototype.onKeyUp_ = function(evt) { ns.KeyboardEventService.prototype.onKeyUp_ = function(evt) {
var isMac = false; var isMac = false;
if (navigator.appVersion.indexOf("Mac")!=-1) { if (navigator.appVersion.indexOf("Mac")!=-1) {
// Welcome in mac world where vowels are consons and meta used instead of ctrl: // Welcome in mac world where vowels are consons and meta used instead of ctrl:
@@ -56,4 +54,11 @@
} }
}; };
/**
* @public
*/
ns.KeyboardEventService.prototype.init = function() {
$(document.body).keydown($.proxy(this.onKeyUp_, this));
};
})(); })();