We can handle any Unicode codepoint now, so stop replacing symbols.
import KeyTable from "./keysym.js";
import keysyms from "./keysymdef.js";
import KeyTable from "./keysym.js";
import keysyms from "./keysymdef.js";
-export function substituteCodepoint(cp) {
- // Any Unicode code points which do not have corresponding keysym entries
- // can be swapped out for another code point by adding them to this table
- var substitutions = {
- // {S,s} with comma below -> {S,s} with cedilla
- 0x218 : 0x15e,
- 0x219 : 0x15f,
- // {T,t} with comma below -> {T,t} with cedilla
- 0x21a : 0x162,
- 0x21b : 0x163
- };
-
- var sub = substitutions[cp];
- return sub ? sub : cp;
-}
-
function isMac() {
return navigator && !!(/mac/i).exec(navigator.platform);
}
function isMac() {
return navigator && !!(/mac/i).exec(navigator.platform);
}
codepoint = evt.keyCode;
}
if (codepoint) {
codepoint = evt.keyCode;
}
if (codepoint) {
- return keysyms.lookup(substituteCodepoint(codepoint));
+ return keysyms.lookup(codepoint);
}
// we could check evt.key here.
// Legal values are defined in http://www.w3.org/TR/DOM-Level-3-Events/#key-values-list,
}
// we could check evt.key here.
// Legal values are defined in http://www.w3.org/TR/DOM-Level-3-Events/#key-values-list,
- describe('substituteCodepoint', function() {
- it('should replace characters which don\'t have a keysym', function() {
- expect(KeyboardUtil.substituteCodepoint('Ș'.charCodeAt())).to.equal('Ş'.charCodeAt());
- expect(KeyboardUtil.substituteCodepoint('ș'.charCodeAt())).to.equal('ş'.charCodeAt());
- expect(KeyboardUtil.substituteCodepoint('Ț'.charCodeAt())).to.equal('Ţ'.charCodeAt());
- expect(KeyboardUtil.substituteCodepoint('ț'.charCodeAt())).to.equal('ţ'.charCodeAt());
- });
- it('should pass other characters through unchanged', function() {
- expect(KeyboardUtil.substituteCodepoint('T'.charCodeAt())).to.equal('T'.charCodeAt());
- });
- });
-
describe('nonCharacterKey', function() {
it('should recognize the right keys', function() {
expect(KeyboardUtil.nonCharacterKey({keyCode: 0xd}), 'enter').to.be.defined;
describe('nonCharacterKey', function() {
it('should recognize the right keys', function() {
expect(KeyboardUtil.nonCharacterKey({keyCode: 0xd}), 'enter').to.be.defined;
expect(KeyboardUtil.getKeysym({which: 0x43, shiftKey: false})).to.be.equal(0x63);
expect(KeyboardUtil.getKeysym({which: 0x43, shiftKey: true})).to.be.equal(0x43);
});
expect(KeyboardUtil.getKeysym({which: 0x43, shiftKey: false})).to.be.equal(0x63);
expect(KeyboardUtil.getKeysym({which: 0x43, shiftKey: true})).to.be.equal(0x43);
});
- it('should substitute where applicable', function() {
- expect(KeyboardUtil.getKeysym({char : 'Ș'})).to.be.equal(0x1aa);
- });
});
describe('Modifier Sync', function() { // return a list of fake events necessary to fix modifier state
});
describe('Modifier Sync', function() { // return a list of fake events necessary to fix modifier state