Permalink
Browse files

keysyms not 1:1 with unicode, fromUnicode returns a list now

  • Loading branch information...
1 parent 2dd970b commit 52cc13ad1908f3abb3890c0775b709eea5283c3d @substack committed Nov 19, 2010
Showing with 15 additions and 10 deletions.
  1. +8 −7 README.markdown
  2. +1 −1 data/keysyms.json
  3. +3 −1 index.js
  4. +3 −1 scrape.js
View
15 README.markdown
@@ -25,17 +25,18 @@ except keysym and unicode are converted from hexadecimal strings to integers.
Example
=======
-Look up a keysym record from its unicode position
--------------------------------------------------
+Look up keysym records from a unicode position
+----------------------------------------------
var ks = require('keysym');
console.dir(ks.fromUnicode(8))
Output:
- { keysym: 65288
- , unicode: 8
- , status: 'f'
- , name: 'BackSpace'
- }
+ [ { keysym: 65288
+ , unicode: 8
+ , status: 'f'
+ , name: 'BackSpace'
+ }
+ ]
Installation
============
View
2 data/keysyms.json
1 addition, 1 deletion not shown because the diff is too large. Please use a local Git client to view these changes.
View
4 index.js
@@ -9,7 +9,9 @@ exports.fromKeysym = function (keysym) {
};
exports.fromUnicode = function (code) {
- return data.records[data.unicodes[code]]
+ return data.unicodes[code].map(function (i) {
+ return data.records[i]
+ });
};
exports.fromName = function (name) {
View
4 scrape.js
@@ -19,8 +19,10 @@ Lazy(s).lines.map(String)
var i = data.records.length;
data.records.push(rec);
+ if (!data.unicodes[rec.unicode]) data.unicodes[rec.unicode] = [];
+ data.unicodes[rec.unicode].push(i);
+
data.keysyms[rec.keysym] = i;
- data.unicodes[rec.unicode] = i;
data.names[rec.name] = i;
});
fs.createWriteStream(__dirname + '/data/keysyms.json')

0 comments on commit 52cc13a

Please sign in to comment.