mirror of
https://github.com/flynx/PortableMag.git
synced 2025-10-28 10:40:07 +00:00
updated keyboard handler with the rest of the key names (number row and punctuation)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
bcc490ab8d
commit
a29299d8be
2
TODO.otl
2
TODO.otl
@ -6,7 +6,7 @@
|
||||
[_] load/save state (migrate)
|
||||
[_] load/save from JSON (migrate)
|
||||
[_] basic instructions/docs...
|
||||
[_] page settngs in full view editor
|
||||
[_] page settings in full view editor
|
||||
| could even be fixed...
|
||||
[_] 37% Version 1.0 checklist (migration to layout.html)
|
||||
[X] page scaling for full page view
|
||||
|
||||
12
index.html
12
index.html
@ -157,8 +157,7 @@ var keyboard_config = {
|
||||
title: 'Editor mode.',
|
||||
doc: '',
|
||||
|
||||
// 0
|
||||
48: function(){
|
||||
'0': function(){
|
||||
var n = getPageNumber()
|
||||
if(togglePageView('?') == 'on'){
|
||||
setMagazineScale(getPageTargetScale(1))
|
||||
@ -167,25 +166,22 @@ var keyboard_config = {
|
||||
}
|
||||
setCurrentPage(n)
|
||||
},
|
||||
Esc: 48,
|
||||
Esc: '0',
|
||||
|
||||
// +
|
||||
187: function(){
|
||||
'=': function(){
|
||||
var n = getPageNumber()
|
||||
setMagazineScale(Math.min(
|
||||
getMagazineScale() * 1.2,
|
||||
getPageTargetScale(1)))
|
||||
setCurrentPage(n)
|
||||
},
|
||||
// -
|
||||
189: function(){
|
||||
'-': function(){
|
||||
var n = getPageNumber()
|
||||
setMagazineScale(Math.max(
|
||||
getMagazineScale() * 0.8,
|
||||
getPageTargetScale(PAGES_IN_RIBBON*2)))
|
||||
setCurrentPage(n)
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
// ignore all keys except Esc here...
|
||||
|
||||
@ -10,8 +10,18 @@
|
||||
|
||||
/*********************************************************************/
|
||||
|
||||
// Neither _SPECIAL_KEYS nor _KEY_CODES are meant for direct access, use
|
||||
// toKeyName(<code>) and toKeyCode(<name>) for a more uniform access.
|
||||
//
|
||||
// NOTE: these are un-shifted ASCII key names rather than actual key
|
||||
// code values.
|
||||
// NOTE: ASCII letters (capital) are not present because they actually
|
||||
// match their key codes and are accessible via:
|
||||
// String.fromCharCode(<code>) or <letter>.charCodeAt(0)
|
||||
// NOTE: the lower case letters are accessible by adding 32 to the
|
||||
// capital key code.
|
||||
// NOTE: don't understand why am I the one who has to write this...
|
||||
var SPECIAL_KEYS = {
|
||||
var _SPECIAL_KEYS = {
|
||||
// Special Keys...
|
||||
9: 'Tab', 33: 'PgUp', 45: 'Ins',
|
||||
13: 'Enter', 34: 'PgDown', 46: 'Del',
|
||||
@ -27,18 +37,30 @@ var SPECIAL_KEYS = {
|
||||
113: 'F2', 117: 'F6', 121: 'F10',
|
||||
114: 'F3', 118: 'F7', 122: 'F11',
|
||||
115: 'F4', 119: 'F8', 123: 'F12',
|
||||
|
||||
// number row..
|
||||
49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
|
||||
54: '6', 55: '7', 56: '8', 57: '9', 48: '0',
|
||||
|
||||
// punctuation...
|
||||
// top row...
|
||||
192: '`', 189: '-', 187: '=',
|
||||
// right side of keyboard...
|
||||
219: '[', 221: ']', 220: '\\',
|
||||
186: ';', 222: '\'',
|
||||
188: ',', 190: '.', 191: '/',
|
||||
}
|
||||
|
||||
var KEY_CODES = {}
|
||||
for(var k in SPECIAL_KEYS){
|
||||
KEY_CODES[SPECIAL_KEYS[k]] = k
|
||||
var _KEY_CODES = {}
|
||||
for(var k in _SPECIAL_KEYS){
|
||||
_KEY_CODES[_SPECIAL_KEYS[k]] = k
|
||||
}
|
||||
|
||||
|
||||
// XXX some keys look really wrong...
|
||||
function toKeyName(code){
|
||||
// check for special keys...
|
||||
var k = SPECIAL_KEYS[code]
|
||||
var k = _SPECIAL_KEYS[code]
|
||||
if(k != null){
|
||||
return k
|
||||
}
|
||||
@ -52,8 +74,8 @@ function toKeyName(code){
|
||||
}
|
||||
|
||||
function toKeyCode(c){
|
||||
if(c in KEY_CODES){
|
||||
return KEY_CODES[c]
|
||||
if(c in _KEY_CODES){
|
||||
return _KEY_CODES[c]
|
||||
}
|
||||
return c.charCodeAt(0)
|
||||
}
|
||||
@ -89,7 +111,7 @@ var KEYBOARD_HANDLER_PROPAGATE = true
|
||||
*
|
||||
* <key-def> can be:
|
||||
* - explicit key code
|
||||
* - key name, if present in SPECIAL_KEYS)
|
||||
* - key name, if present in _SPECIAL_KEYS)
|
||||
* - key char (uppercase), as is returned by String.fromCharCode(...)
|
||||
*
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user