Emoji backspace fix

This commit is contained in:
Francisco Hodge
2018-08-24 00:40:54 -04:00
parent ad17363173
commit 30603e76b5
4 changed files with 17 additions and 6 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "simple-keyboard", "name": "simple-keyboard",
"version": "2.3.22", "version": "2.3.23",
"description": "On-screen Virtual Keyboard", "description": "On-screen Virtual Keyboard",
"main": "build/index.js", "main": "build/index.js",
"scripts": { "scripts": {
+14 -3
View File
@@ -74,9 +74,20 @@ class Utilities {
let output = input; let output = input;
let newLineOnEnter = options.newLineOnEnter; let newLineOnEnter = options.newLineOnEnter;
if(button === "{bksp}" && output.length > 0) if(button === "{bksp}" && output.length > 0){
output = output.slice(0, -1); /**
else if(button === "{space}") * Emojis are made out of two characters, so we must take a custom approach to trim them.
* For more info: https://mathiasbynens.be/notes/javascript-unicode
*/
let lastTwoChars = output.slice(-2);
let emojiMatched = lastTwoChars.match(/([\uD800-\uDBFF][\uDC00-\uDFFF])/g);
if(emojiMatched){
output = output.slice(0, -2);
} else {
output = output.slice(0, -1);
}
} else if(button === "{space}")
output = output + ' '; output = output + ' ';
else if(button === "{tab}") else if(button === "{tab}")
output = output + "\t"; output = output + "\t";