Using multiple carets in single or multiple textar

2019-06-19 00:27发布

I think I may already know the answer to this one but...

Is it possible to have two carets in a single textbox, or have two separate textboxes focused at the same time allowing the user to type into both symataniously?

I know you can simulate this by adding a keydown listener and making their values match, but I want the visible caret in both fields.

If not, does anyone have any ideas on how to simulate this?

3条回答
该账号已被封号
2楼-- · 2019-06-19 01:07

Check out @Sly_cardinal answer, That does everything you require, it is more off a "heavy" solution, but is certainly the only way you'll get something like this. It can be customized with a bit of work but its definitely the correct answer.

+1 @Sly_cardinal - Just what i've been looking for!


Rendering a text area is handled by the user agent (browser), we can control the style, look and feel, but unfortunately not the functionality (To be able to do multiple cursors anyway).

Bummer.. This would be amazing!

查看更多
做自己的国王
3楼-- · 2019-06-19 01:10

Try

<html>
<body>
    <input id="edValue" type="text" onKeyPress="edValueKeyPress()" onKeyUp="edValueKeyPress()"><br>
    <span id="lblValue">The text box contains: </span>
        <input id="secvalue" type="text">
</body>

<script>
    function edValueKeyPress()
    {
        var edValue = document.getElementById("edValue");
        var s = edValue.value;

        var lblValue = document.getElementById("secvalue");
        lblValue.value = s;


    }
</script>    

</html>

I suppose this is your requirement

查看更多
Melony?
4楼-- · 2019-06-19 01:20

Ace editor supports multiple cursors/carets like Sublime Text:

http://ajaxorg.github.io/ace/

Ctrl+Click (or Cmd(⌘)+Click on OS X) in the live demo on that page to get multiple cursors and type away!

You can also select a bunch of code and use Tab to indent a tab space, or Shift+Tab to outdent a tab space.

查看更多
登录 后发表回答