about summary refs log tree commit diff stats
path: root/js/inknswitch/ink.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/inknswitch/ink.js')
-rw-r--r--js/inknswitch/ink.js24
1 files changed, 18 insertions, 6 deletions
diff --git a/js/inknswitch/ink.js b/js/inknswitch/ink.js
index 317dbcb..03f5991 100644
--- a/js/inknswitch/ink.js
+++ b/js/inknswitch/ink.js
@@ -1,3 +1,5 @@
+document.getElementById('noteArea').focus(); // ensures that textarea is focused when the page loads
+
 const canvas = document.getElementById('drawingArea');
 const ctx = canvas.getContext('2d');
 
@@ -110,18 +112,29 @@ const toggle = () => {
         noteArea.style.backgroundColor = 'rgba(255, 255, 255, 0.25)';
         noteArea.style.color = '#bbb';
         canvas.style.cursor = 'pointer';
-        toggleButton.textContent = 'Write'
+        canvas.focus();
+        noteArea.blur();
+        localStorage.setItem('noteContents', noteArea.value);
+        localStorage.setItem('noteContent', noteArea.value);
+        // toggleButton.textContent = 'Write'
     } else {
         // Note mode
         canvas.style.pointerEvents = 'none';
         noteArea.style.pointerEvents = 'auto';
         noteArea.style.backgroundColor = 'rgba(255, 255, 255, 0.75)';
         noteArea.style.color = 'black';
-        toggleButton.textContent = 'Draw'
+        canvas.blur();
+        noteArea.focus();
+        localStorage.setItem('noteContents', noteArea.value);
+        localStorage.setItem('noteContent', noteArea.value);
+        // toggleButton.textContent = 'Draw'
     }
 };
 
-/*
+/* 
+// This button doesn't work great
+// the hope was that it'd work on mobile
+// one day I'll fix this...one day
 const toggleButton = document.getElementById('toggleButton');
 toggleButton.style.pointerEvents = 'auto';
 toggleButton.addEventListener('click', toggleMode);
@@ -132,10 +145,9 @@ function toggleMode() {
 }
 */
 
-
 document.addEventListener('keydown', (e) => {
-    // Cmd or Ctrl and D key to toggle modes
-    if ((e.metaKey || e.ctrlKey) && e.key === 'd') {
+    // Cmd or Ctrl and D/Cmd or Ctrl and 1 to toggle modes
+    if (((e.metaKey || e.ctrlKey) && e.key === 'd') || ((e.metaKey || e.ctrlKey) && e.key === '1')) {
         e.preventDefault();
         toggle();
     }