blob: 81f2e6b3199a250afb8aad89601aaee024daf555 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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() {
}
}
|