aboutsummaryrefslogtreecommitdiff
path: root/src/content
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-08-12 11:08:43 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-08-12 11:22:09 +0900
commite73d405c5640afda27775285f19516a271b5cefb (patch)
treeda08aefd9c5f718f96aff84c4f2c95554796999b /src/content
parentd169661e030e53b6a1635f86205f9fc42d2b7ef2 (diff)
message passing between background and content
Diffstat (limited to 'src/content')
-rw-r--r--src/content/index.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/content/index.js b/src/content/index.js
new file mode 100644
index 0000000..0fa0720
--- /dev/null
+++ b/src/content/index.js
@@ -0,0 +1,9 @@
+window.addEventListener("keypress", (e) => {
+ browser.runtime.sendMessage({
+ which: e.which || e.keyCode,
+ }).then((msg) => {
+ console.log(`Message from the background script: ${msg.response}`);
+ }, (err) => {
+ console.log(`Error: ${err}`);
+ });
+});