Merge pull request #537 from ueokande/space-key-map

Space key map
jh-changes
Shin'ya Ueoka 6 years ago committed by GitHub
commit 8a0d9e5efb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      karma.conf.js
  2. 3
      src/shared/utils/keys.js
  3. 20
      test/shared/utils/keys.test.js

@ -24,7 +24,7 @@ module.exports = function (config) {
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
browsers: ['Firefox'],
browsers: ['FirefoxHeadless'],
singleRun: true,

@ -1,4 +1,7 @@
const modifiedKeyName = (name) => {
if (name === ' ') {
return 'Space';
}
if (name.length === 1) {
return name;
} else if (name === 'Escape') {

@ -35,6 +35,17 @@ describe("keys util", () => {
expect(k.altKey).to.be.false;
expect(k.metaKey).to.be.false;
});
it('returns from keyboard input Crtl+Space', () => {
let k = keys.fromKeyboardEvent({
key: ' ', shiftKey: false, ctrlKey: true, altKey: false, metaKey: false
});
expect(k.key).to.equal('Space');
expect(k.shiftKey).to.be.false;
expect(k.ctrlKey).to.be.true;
expect(k.altKey).to.be.false;
expect(k.metaKey).to.be.false;
});
});
describe('fromMapKey', () => {
@ -100,6 +111,15 @@ describe("keys util", () => {
expect(key.altKey).to.be.false;
expect(key.metaKey).to.be.false;
});
it('returns for Ctrl+Esc', () => {
let key = keys.fromMapKey('<C-Space>');
expect(key.key).to.equal('Space');
expect(key.shiftKey).to.be.false;
expect(key.ctrlKey).to.be.true;
expect(key.altKey).to.be.false;
expect(key.metaKey).to.be.false;
});
});
describe('fromMapKeys', () => {