{"id":548,"date":"2013-06-26T22:14:30","date_gmt":"2013-06-26T22:14:30","guid":{"rendered":"http:\/\/tregner.com\/flare-blog\/?p=548"},"modified":"2013-06-26T22:14:30","modified_gmt":"2013-06-26T22:14:30","slug":"clear-a-flare-html5-search-field-with-the-escape-key","status":"publish","type":"post","link":"https:\/\/tregner.com\/flare-blog\/clear-a-flare-html5-search-field-with-the-escape-key\/","title":{"rendered":"Clear a Flare HTML5 Search Field with the Escape Key"},"content":{"rendered":"<p>If you want the search field in Flare HTML5 output to clear when escape is pressed, add the following to the toolbar JavaScript.<\/p>\n<pre class=\"lang:js decode:true\" title=\"Escape Clears the Search Field\">window.onload = function() {\r\n    $(\"#search-field\").keyup(function (e) {\r\n        if (e.keyCode == 27) { $(\"#search-field\").val(\"\"); }\r\n    });\r\n}<\/pre>\n<p>If there is already a window.onload assignment, just add the inner part to the existing assignment.<\/p>\n<p>Resources:<\/p>\n<ul>\n<li><a style=\"line-height: 1.714285714; font-size: 1rem;\" href=\"http:\/\/stackoverflow.com\/questions\/3369593\/how-to-detect-escape-key-press-with-javascript\" target=\"_blank\">Stack Overflow: How to detect escape key press with javascript [duplicate]<\/a><\/li>\n<li><a style=\"line-height: 1.714285714; font-size: 1rem;\" href=\"http:\/\/api.jquery.com\/id-selector\/\" target=\"_blank\">jQuery:\u00a0ID Selector (\u201c#id\u201d)<\/a><\/li>\n<li><a style=\"line-height: 1.714285714; font-size: 1rem;\" href=\"http:\/\/api.jquery.com\/keyup\/\" target=\"_blank\">jQuery: .keyUp()<\/a><\/li>\n<li><a style=\"line-height: 1.714285714; font-size: 1rem;\" href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/event.keyCode\" target=\"_blank\">MDN: event.keyCode<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want the search field in Flare HTML5 output to clear when escape is pressed, add the following to the toolbar JavaScript. window.onload = function() { $(&#8220;#search-field&#8221;).keyup(function (e) { if (e.keyCode == 27) { $(&#8220;#search-field&#8221;).val(&#8220;&#8221;); } }); } If there is already a window.onload assignment, just add the inner part to the existing assignment.&hellip; <a class=\"more-link\" href=\"https:\/\/tregner.com\/flare-blog\/clear-a-flare-html5-search-field-with-the-escape-key\/\">Continue reading <span class=\"screen-reader-text\">Clear a Flare HTML5 Search Field with the Escape Key<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[69,53,61,5,70],"_links":{"self":[{"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/posts\/548"}],"collection":[{"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/comments?post=548"}],"version-history":[{"count":3,"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/posts\/548\/revisions"}],"predecessor-version":[{"id":551,"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/posts\/548\/revisions\/551"}],"wp:attachment":[{"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/media?parent=548"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/categories?post=548"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tregner.com\/flare-blog\/wp-json\/wp\/v2\/tags?post=548"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}