summaryrefslogtreecommitdiff
path: root/keyboard-component.js
diff options
context:
space:
mode:
Diffstat (limited to 'keyboard-component.js')
-rw-r--r--keyboard-component.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/keyboard-component.js b/keyboard-component.js
new file mode 100644
index 0000000..ce590ae
--- /dev/null
+++ b/keyboard-component.js
@@ -0,0 +1,22 @@
+typingMessageComponent = {
+ keyDown: function(e){
+ if(e.keyCode == 48 && e.key == "Delete"){ // Mark delete as backspace
+ e.keyCode = 8
+ }
+
+ if(e.keyCode >= 32 && e.key.length == 1){ // Printable character (probably)
+ currentMessageText += e.key
+ } else if(e.keyCode == 13){ // Enter
+ currentMessageText += "\n";
+ } else if(e.keyCode == 8) { // delete
+ if(currentMessageText.length >= 1){
+ currentMessageText = currentMessageText.substring(0, currentMessageText.length - 1)
+ } else {
+ currentMessageText = ""
+ }
+ }
+ currentMessageParts = split_into_parts(currentMessageText)
+ currentMessageText = currentMessageParts.join("")
+ mouseIsDown = false
+ }
+} \ No newline at end of file