{"id":2620,"date":"2012-09-06T12:29:31","date_gmt":"2012-09-06T18:29:31","guid":{"rendered":"http:\/\/bililite.com\/blog\/?p=2620"},"modified":"2012-09-06T12:31:28","modified_gmt":"2012-09-06T18:31:28","slug":"new-special-keys-for-sendkeys","status":"publish","type":"post","link":"https:\/\/bililite.com\/blog\/2012\/09\/06\/new-special-keys-for-sendkeys\/","title":{"rendered":"New special keys for <code>sendkeys<\/code>"},"content":{"rendered":"<p>One of the nice things about my <code><a href=\"\/blog\/2011\/01\/23\/improved-sendkeys\/\" title=\"Improved sendkeys\">sendkeys<\/a><\/code> 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 <code class=\"language-html\" >&lt;a href=\"\"&gt;&lt;\/a&gt;<\/code> and places the insertion point between the quotes so I can start typing the link.<\/p>\r\n<p>I added two things to <code>sendkeys<\/code> to make that possible: <code>{selection}<\/code>, which remembers the original selected text and inserts it, and <code>{mark}<\/code>, which records the location of the insertion point and sets the selection there after the string is inserted. Thus, <code class=\"language-javascript\" >'&lt;a href=\"{mark}\"&gt;{selection}&lt;\/a&gt;'<\/code> accomplishes the same thing and I can use it in my home-grown text editors.<\/p>\r\n<script src='http:\/\/bililite.com\/inc\/package.php\/jquery.sendkeys-package.js'><\/script>\r\n<pre><code class=\"language-html demo\" >&lt;input class=text \/&gt; &lt;input type=button class=test value=\"Try It\" \/&gt;<\/code><\/pre>\r\n\r\n<pre><code class=\"language-javascript demo\" >$('input.test').click(function(){ $('input.text').sendkeys('&lt;a href=\"{mark}\"&gt;{selection}&lt;\/a&gt;'); });<\/code><\/pre>\r\n","protected":false},"excerpt":{"rendered":"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 &lt;a href=\"\"&gt;&lt;\/a&gt; and places the insertion point between the quotes so I can start typing the link. I [&hellip;]","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,5],"tags":[],"_links":{"self":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/2620"}],"collection":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/comments?post=2620"}],"version-history":[{"count":9,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/2620\/revisions"}],"predecessor-version":[{"id":2628,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/2620\/revisions\/2628"}],"wp:attachment":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/media?parent=2620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/categories?post=2620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/tags?post=2620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}