Fix Ctrl+V inserting v and add Delete key text editing

This commit is contained in:
Jage9
2026-02-22 03:21:58 -05:00
parent e433f3b142
commit 95e95e988b
3 changed files with 19 additions and 1 deletions

View File

@@ -17,6 +17,10 @@ export function applyTextInput(
newString = newString.slice(0, cursorPos - 1) + newString.slice(cursorPos);
newCursorPos = cursorPos - 1;
}
} else if (lowerKey === 'delete') {
if (cursorPos < newString.length) {
newString = newString.slice(0, cursorPos) + newString.slice(cursorPos + 1);
}
} else if (lowerKey === 'home') {
newCursorPos = 0;
} else if (lowerKey === 'end') {
@@ -92,6 +96,7 @@ export function mapTextInputKey(code: string, key: string): string {
if (code === 'ArrowLeft') return 'arrowleft';
if (code === 'ArrowRight') return 'arrowright';
if (code === 'Backspace') return 'backspace';
if (code === 'Delete') return 'delete';
if (code === 'Home') return 'home';
if (code === 'End') return 'end';
return key;
@@ -182,3 +187,8 @@ export function describeBackspaceDeletedCharacter(text: string, cursorPos: numbe
if (cursorPos <= 0 || cursorPos > text.length) return null;
return describeCharacter(text[cursorPos - 1]);
}
export function describeDeleteDeletedCharacter(text: string, cursorPos: number): string | null {
if (cursorPos < 0 || cursorPos >= text.length) return null;
return describeCharacter(text[cursorPos]);
}