Results 1 to 5 of 5

Thread: Java script for Keypress and the script to work

  1. #1
    Join Date
    Sep 2010
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Java script for Keypress and the script to work

    I need to assign a key in the javascript to actually make the javascript work,.

    I have a bookmark in chrome , a javascript , which actually works when clicked on it .,. but how can i edit it so that i can actually make it work on click a key or combination of keys.

    Thanks in advance ., pls help ., urgent

    Nani

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,475
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    We don't really do urgent here. And your post is unclear. What do you want to happen? Is it:

    1. When pressing a key or key combo in your Chrome browser it activates your bookmark.

      or:

    2. When a user comes to a page on the web, they can press a key or key combo to activate a script based upon your bookmark.


    Or are you after something else?

    If it's #1, see:

    http://www.chromeplugins.org/google/...arks-7571.html

    or use another browser that already has this feature.

    If it's #2, we need to see the code of the bookmark in order to know if this is even something that can be done live on the web.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    aravitejareddy (09-05-2010)

  4. #3
    Join Date
    Sep 2010
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    thanks for the reply.,.

    and sorry for tagging it urgent .,.

    i want to declare the key or keycombo in the script itself .,.

    the script is for catching the selected text on the webpage and opening a new tab(or window) and doing an exact search search of the selected text using google.com .,.,

    So I want it to work it this way .,

    select the text
    press a key
    and it opens a new tab (or window) with an xact search .,.


    hope now its clear

    thanks
    Nani

  5. #4
    Join Date
    Sep 2010
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks for your reply for my question

    I want the script to be used as a bookmarklet or an extension .,. since an extension is lil hard a bookmarklet with the javascript is fine .,.

    My Javascript bookmarklet already does this thing

    When text is selected and clicked on the bookmarklet it opens a new tab and does an exact search with the snippet of the text selected using google.com/search?q="(myselected text)"

    Now i want it to do automatically on a key press

    When certain text is selected and selected key is pressed it should do the work as when i clicked on the bookmarklet.

    Note: I'm using this bookmarklet in CHROME

    my javascript is
    javascript:a = "" + (window.getSelection() ? document.getSelection() : document.selection.createRange().text); if (a!=null)window.open("http://www.google.com/search?q=\"" + escape(a)+ "\"");

  6. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,475
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Only thing I know for that is (as mentioned before):

    http://www.chromeplugins.org/google/...arks-7571.html

    You have to join the forum to see the links.

    But it bears mentioning that even without a bookmarklet, Chrome has this feature:

    Highlight text, right click on it and select:

    Search Google for 'your highlighted text'

    This opens a new tab of Google with the exact search on the highlighted text.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •