aboutsummaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-10-01 17:17:20 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-10-01 17:18:26 +0900
commita74a8b537e8a82f1af63667fd73869b83d8b7d0d (patch)
tree64d5ae21d2510475af9516efb061ea912b8decff /src/shared
parent825bb6347623d998c671d3d42268230d1a783d76 (diff)
BackgroundInputComponent
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/keys.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/shared/keys.js b/src/shared/keys.js
new file mode 100644
index 0000000..aca050e
--- /dev/null
+++ b/src/shared/keys.js
@@ -0,0 +1,21 @@
+const asKeymapChars = (keys) => {
+ return keys.map((k) => {
+ let c = String.fromCharCode(k.code);
+ if (k.ctrl) {
+ return '<C-' + c.toUpperCase() + '>';
+ }
+ return c;
+ }).join('');
+};
+
+const asCaretChars = (keys) => {
+ return keys.map((k) => {
+ let c = String.fromCharCode(k.code);
+ if (k.ctrl) {
+ return '^' + c.toUpperCase();
+ }
+ return c;
+ }).join('');
+};
+
+export { asKeymapChars, asCaretChars };