Skip to content

Commit fdde574

Browse files
authored
Merge pull request #37 from aldinezi/expand_backspace
Check selection and delete selected on backspace.
2 parents 8bfd533 + d12cb79 commit fdde574

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/keyboard.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,12 @@
166166
},
167167
168168
backspace(caret, text) {
169-
text = text.substring(0, caret.start - 1) + text.substring(caret.start);
170-
caret.start -= 1;
169+
if (caret.start < caret.end) {
170+
text = text.substring(0, caret.start) + text.substring(caret.end);
171+
} else {
172+
text = text.substring(0, caret.start - 1) + text.substring(caret.start);
173+
caret.start -= 1;
174+
}
171175
caret.end = caret.start;
172176
return text;
173177
},

0 commit comments

Comments
 (0)