parent
b5e52a75d7
commit
eff8d9a83e
2 changed files with 33 additions and 16 deletions
@ -0,0 +1,31 @@ |
||||
import messages from '../content/messages'; |
||||
|
||||
export default class ContentInputComponent { |
||||
constructor(target) { |
||||
target.addEventListener('keypress', this.onKeyPress.bind(this)); |
||||
target.addEventListener('keydown', this.onKeyDown.bind(this)); |
||||
target.addEventListener('keyup', this.onKeyUp.bind(this)); |
||||
} |
||||
|
||||
onKeyPress(e) { |
||||
if (e.target instanceof HTMLInputElement || |
||||
e.target instanceof HTMLTextAreaElement || |
||||
e.target instanceof HTMLSelectElement) { |
||||
if (e.key === 'Escape' && e.target.blur) { |
||||
e.target.blur(); |
||||
} |
||||
return; |
||||
} |
||||
browser.runtime.sendMessage({ |
||||
type: messages.KEYDOWN, |
||||
code: e.which, |
||||
ctrl: e.ctrlKey |
||||
}); |
||||
} |
||||
|
||||
onKeyDown() { |
||||
} |
||||
|
||||
onKeyUp() { |
||||
} |
||||
} |
Reference in new issue