diff --git a/src/content/components/common/input.js b/src/content/components/common/input.js index 9af9fbe..f285b0c 100644 --- a/src/content/components/common/input.js +++ b/src/content/components/common/input.js @@ -1,6 +1,17 @@ +const modifierdKeyName = (name) => { + if (name.length === 1) { + return name.toUpperCase(); + } else if (name === 'Escape') { + return 'Esc'; + } + return name; +}; + const mapKey = (e) => { if (e.ctrlKey) { - return ''; + return ''; + } else if (e.shiftKey && e.key.length !== 1) { + return ''; } return e.key; }; diff --git a/test/content/components/common/input.test.js b/test/content/components/common/input.test.js index d4f554a..912ac34 100644 --- a/test/content/components/common/input.test.js +++ b/test/content/components/common/input.test.js @@ -40,6 +40,30 @@ describe('InputComponent', () => { component.onKeyDown({ key: 'a', ctrlKey: true }); }) + it('press X', () => { + let component = new InputComponent(window.document); + component.onKey((key) => { + expect(key).is.equals('X'); + }); + component.onKeyDown({ key: 'X', shiftKey: true }); + }) + + it('press + ', () => { + let component = new InputComponent(window.document); + component.onKey((key) => { + expect(key).is.equals(''); + }); + component.onKeyDown({ key: 'Escape', shiftKey: true }); + }) + + it('press + ', () => { + let component = new InputComponent(window.document); + component.onKey((key) => { + expect(key).is.equals(''); + }); + component.onKeyDown({ key: 'Escape', ctrlKey: true }); + }) + it('does not invoke only meta keys', () => { let component = new InputComponent(window.document); component.onKey((key) => {