XF 2 STRG+B = bold; i need STRG+{char} for icode

Robert9

Well-known member
Today, I realized how much it annoys me to set parts of a text in iCode. You can't even click on the template name and then the button without selecting the space behind the word as well.

I would like to have:

a) A key shortcut (CTRL + {something available and near the left CTRL key})
b) Avoidance of the space being included in the bbCode.

Although b) might not be possible, at least a) should be achievable similarly to b, i, s, right?
 
Last edited:
 
I found my solution here:



'test'
test

Still too complicated! Who wants to press SHIFT and a char far away from anything?
 
Lalala lalala hahaha hahaha?

There must be another character! Who has time for shift plus `
while you always need another key to finish that "´".
 
Like this?

Code:
<script>
document.addEventListener('keydown', function (event) {
    if (event.ctrlKey && event.key === 'q') { // STRG + Q als Beispiel
        event.preventDefault();
        var textarea = document.querySelector('textarea'); // Den Textarea-Editor finden
        if (textarea) {
            var start = textarea.selectionStart;
            var end = textarea.selectionEnd;
            var selectedText = textarea.value.substring(start, end);

            // Verhindert, dass ein Leerzeichen nach dem BBCode eingefügt wird
            var before = textarea.value.substring(0, start);
            var after = textarea.value.substring(end, textarea.value.length);
            textarea.value = before + '[icode]' + selectedText.trim() + '[/icode]' + after;

            // Setzt den Cursor an das Ende des eingefügten BBCode
            textarea.selectionStart = textarea.selectionEnd = start + 7 + selectedText.trim().length; // 7 für '[icode]'
        }
    }
});
</script>
 
Back
Top Bottom