mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-11-18 14:55:34 +08:00
inserting tab on cursor
This commit is contained in:
parent
589cb91459
commit
c0a78cd3b6
1 changed files with 17 additions and 3 deletions
|
|
@ -4764,9 +4764,23 @@ function handleTab(event) {
|
|||
}
|
||||
if ($("#customTextPopup .textarea").is(":focus")) {
|
||||
event.preventDefault();
|
||||
$("#customTextPopup .textarea").val(
|
||||
$("#customTextPopup .textarea").val() + "\t"
|
||||
);
|
||||
|
||||
let area = $("#customTextPopup .textarea")[0];
|
||||
|
||||
var start = area.selectionStart;
|
||||
var end = area.selectionEnd;
|
||||
|
||||
// set textarea value to: text before caret + tab + text after caret
|
||||
area.value =
|
||||
area.value.substring(0, start) + "\t" + area.value.substring(end);
|
||||
|
||||
// put caret at right position again
|
||||
area.selectionStart = area.selectionEnd = start + 1;
|
||||
|
||||
// event.preventDefault();
|
||||
// $("#customTextPopup .textarea").val(
|
||||
// $("#customTextPopup .textarea").val() + "\t"
|
||||
// );
|
||||
return;
|
||||
} else if (
|
||||
!event.ctrlKey &&
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue