aboutsummaryrefslogtreecommitdiff
path: root/src/components/content-input.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/content-input.js')
-rw-r--r--src/components/content-input.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/components/content-input.js b/src/components/content-input.js
new file mode 100644
index 0000000..81f2e6b
--- /dev/null
+++ b/src/components/content-input.js
@@ -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() {
+ }
+}