On specific key press event in chrome extension -
i want make google chrome extension, in there simple index.html. on page when i'll press alt+ctrl+a mouse focus should on first text box.
i'm having difficulties how implement code keyboard shortcuts.
you might want accesskey
syntax:
http://www.cs.tut.fi/~jkorpela/forms/accesskey.html#ex
hth :)
edit: right, page example wasn't here's reference implementation.
basically, want add accesskey="f"
c-a-f call attention input field.
slightly modified example wikipedia's basic search form:
<form action="http://en.wikipedia.org/w/index.php" id="searchform"> <div id="simplesearch"> <input type="text" name="search" value="example text" title="search wikipedia [f]" accesskey="f" id="searchinput" /> <button type="submit" name="button" title="search wikipedia text" id="searchbutton"><img src="foo.png" alt="search" title="search" /></button> <input type='hidden' name="title" value="special:search"/> </div> </form>
in example, pushing c-a-f should bring browser focus desired box.
while you're @ it, might want have javascript tied form if user sleects field using mouse, it'll still automatically have text selected easier input.
first, put in header (or js file):
function selectall(id) { document.getelementbyid(id).focus(); document.getelementbyid(id).select(); }
... add onclick event input field looke this: onclick="selectall('searchinput');"
, resulting in line:
<input type="text" name="search" value="example text" title="search wikipedia [f]" accesskey="f" id="searchinput" onclick="selectall('searchinput');" />
important blog for every one. Thanks for posting.
ReplyDeletewww.clippingpathquick.com