Skip to content

New special keys for sendkeys

One of the nice things about my sendkeys plugin is the fact that it's easy to add new "special keys." I have a macro to create a link in Notepad++: it takes the selection, wraps it in <a href=""></a> and places the insertion point between the quotes so I can start typing the link.

I added two things to sendkeys to make that possible: {selection}, which remembers the original selected text and inserts it, and {mark}, which records the location of the insertion point and sets the selection there after the string is inserted. Thus, '<a href="{mark}">{selection}</a>' accomplishes the same thing and I can use it in my home-grown text editors.

<input class=text /> <input type=button class=test value="Try It" />
$('input.test').click(function(){ $('input.text').sendkeys('<a href="{mark}">{selection}</a>'); });

{ 2 } Comments

  1. Sunil Khaniya | October 17, 2012 at 1:06 am | Permalink

    can I send special keys like function keys(F1, F2…) using sendkeys plugin?

  2. Danny | October 17, 2012 at 5:38 am | Permalink

    @Sunil Khaniya:
    No. sendkeys is for sending characters to input fields. It will not send keystrokes to the browser or the operating system; for security, the browser won’t let Javascript do that.
    –Danny

Post a Comment

Your email is never published nor shared. Required fields are marked *