mirror of
https://github.com/flynx/PortableMag.git
synced 2025-10-29 11:10:08 +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 state (migrate)
|
||||||
[_] load/save from JSON (migrate)
|
[_] load/save from JSON (migrate)
|
||||||
[_] basic instructions/docs...
|
[_] basic instructions/docs...
|
||||||
[_] page settngs in full view editor
|
[_] page settings in full view editor
|
||||||
| could even be fixed...
|
| could even be fixed...
|
||||||
[_] 37% Version 1.0 checklist (migration to layout.html)
|
[_] 37% Version 1.0 checklist (migration to layout.html)
|
||||||
[X] page scaling for full page view
|
[X] page scaling for full page view
|
||||||
|
|||||||
12
index.html
12
index.html
@ -157,8 +157,7 @@ var keyboard_config = {
|
|||||||
title: 'Editor mode.',
|
title: 'Editor mode.',
|
||||||
doc: '',
|
doc: '',
|
||||||
|
|
||||||
// 0
|
'0': function(){
|
||||||
48: function(){
|
|
||||||
var n = getPageNumber()
|
var n = getPageNumber()
|
||||||
if(togglePageView('?') == 'on'){
|
if(togglePageView('?') == 'on'){
|
||||||
setMagazineScale(getPageTargetScale(1))
|
setMagazineScale(getPageTargetScale(1))
|
||||||
@ -167,25 +166,22 @@ var keyboard_config = {
|
|||||||
}
|
}
|
||||||
setCurrentPage(n)
|
setCurrentPage(n)
|
||||||
},
|
},
|
||||||
Esc: 48,
|
Esc: '0',
|
||||||
|
|
||||||
// +
|
'=': function(){
|
||||||
187: function(){
|
|
||||||
var n = getPageNumber()
|
var n = getPageNumber()
|
||||||
setMagazineScale(Math.min(
|
setMagazineScale(Math.min(
|
||||||
getMagazineScale() * 1.2,
|
getMagazineScale() * 1.2,
|
||||||
getPageTargetScale(1)))
|
getPageTargetScale(1)))
|
||||||
setCurrentPage(n)
|
setCurrentPage(n)
|
||||||
},
|
},
|
||||||
// -
|
'-': function(){
|
||||||
189: function(){
|
|
||||||
var n = getPageNumber()
|
var n = getPageNumber()
|
||||||
setMagazineScale(Math.max(
|
setMagazineScale(Math.max(
|
||||||
getMagazineScale() * 0.8,
|
getMagazineScale() * 0.8,
|
||||||
getPageTargetScale(PAGES_IN_RIBBON*2)))
|
getPageTargetScale(PAGES_IN_RIBBON*2)))
|
||||||
setCurrentPage(n)
|
setCurrentPage(n)
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// ignore all keys except Esc here...
|
// 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...
|
// NOTE: don't understand why am I the one who has to write this...
|
||||||
var SPECIAL_KEYS = {
|
var _SPECIAL_KEYS = {
|
||||||
// Special Keys...
|
// Special Keys...
|
||||||
9: 'Tab', 33: 'PgUp', 45: 'Ins',
|
9: 'Tab', 33: 'PgUp', 45: 'Ins',
|
||||||
13: 'Enter', 34: 'PgDown', 46: 'Del',
|
13: 'Enter', 34: 'PgDown', 46: 'Del',
|
||||||
@ -27,18 +37,30 @@ var SPECIAL_KEYS = {
|
|||||||
113: 'F2', 117: 'F6', 121: 'F10',
|
113: 'F2', 117: 'F6', 121: 'F10',
|
||||||
114: 'F3', 118: 'F7', 122: 'F11',
|
114: 'F3', 118: 'F7', 122: 'F11',
|
||||||
115: 'F4', 119: 'F8', 123: 'F12',
|
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 = {}
|
var _KEY_CODES = {}
|
||||||
for(var k in SPECIAL_KEYS){
|
for(var k in _SPECIAL_KEYS){
|
||||||
KEY_CODES[SPECIAL_KEYS[k]] = k
|
_KEY_CODES[_SPECIAL_KEYS[k]] = k
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// XXX some keys look really wrong...
|
// XXX some keys look really wrong...
|
||||||
function toKeyName(code){
|
function toKeyName(code){
|
||||||
// check for special keys...
|
// check for special keys...
|
||||||
var k = SPECIAL_KEYS[code]
|
var k = _SPECIAL_KEYS[code]
|
||||||
if(k != null){
|
if(k != null){
|
||||||
return k
|
return k
|
||||||
}
|
}
|
||||||
@ -52,8 +74,8 @@ function toKeyName(code){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toKeyCode(c){
|
function toKeyCode(c){
|
||||||
if(c in KEY_CODES){
|
if(c in _KEY_CODES){
|
||||||
return KEY_CODES[c]
|
return _KEY_CODES[c]
|
||||||
}
|
}
|
||||||
return c.charCodeAt(0)
|
return c.charCodeAt(0)
|
||||||
}
|
}
|
||||||
@ -89,7 +111,7 @@ var KEYBOARD_HANDLER_PROPAGATE = true
|
|||||||
*
|
*
|
||||||
* <key-def> can be:
|
* <key-def> can be:
|
||||||
* - explicit key code
|
* - 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(...)
|
* - key char (uppercase), as is returned by String.fromCharCode(...)
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user