Skip to content

Commit f7399dd

Browse files
authored
Add support for the delete key (#23)
* add support for the delete key * bump angular keyboard package version
1 parent 59666b2 commit f7399dd

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"name": "@taskbase/angular-keyboard",
3-
"version": "0.0.9"
3+
"version": "0.0.10"
44
}

projects/angular-keyboard/src/lib/fake-input/fake-input.component.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ export class FakeInputComponent implements OnInit, OnDestroy {
141141
[KeyboardCommandButton.ARROW_UP]: () => this.moveCursorUp(),
142142
[KeyboardCommandButton.ARROW_DOWN]: () => this.moveCursorDown(),
143143
[KeyboardCommandButton.ESCAPE]: () => this.angularKeyboardService.inputFocused$.next(null),
144-
[KeyboardCommandButton.ENTER]: () => this.insertChar('\n')
144+
[KeyboardCommandButton.ENTER]: () => this.insertChar('\n'),
145+
[KeyboardCommandButton.DELETE]: () => this.deleteRight()
145146
};
146147
const action = handledEvents[next];
147148
if (action instanceof Function) {
@@ -156,6 +157,15 @@ export class FakeInputComponent implements OnInit, OnDestroy {
156157
}
157158
}
158159

160+
deleteRight() {
161+
this.moveCursorRight();
162+
this.deleteCharLeftAndAdjustCursor();
163+
164+
if (this.suggestionMode === true) {
165+
this.moveCursorRight();
166+
}
167+
}
168+
159169
getText() {
160170
return this.chars
161171
.filter(char => char.charState !== CharState.REMOVED)

projects/angular-keyboard/src/lib/keyboard-commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export enum KeyboardCommandButton {
55
A_B_C = 'ABC',
66
SPECIAL_CHARS = 'SPECIAL_CHARS',
77
BACKSPACE = 'Backspace',
8+
DELETE = 'Delete',
89
ENTER = 'Enter',
910
ESCAPE = 'Escape',
1011
ARROW_LEFT = 'ArrowLeft',

0 commit comments

Comments
 (0)