Keyboard shortcut keys for selecting value from drop down..

Discussion in 'HTML & Website Design' started by toughguy, Feb 22, 2007.

  1. #1
    Hi Friends,
    I want my user to be able to use Keyboard shortcut keys for selecting value from drop down Can it be done? If so, please give some clues..

    Suppose there is a drop-down menu for selecting a country:
    Say it has a list like India, US, Switzerland, Australia. I want to allow my user select a country by focussing on the dropdown and by hitting the HIGHLIGHTED character of the country in the keyboard. Please note the highlighted letter can be anywhere in the work..

    Thanks a lot for the help..

    Regards,
     
    toughguy, Feb 22, 2007 IP
  2. Maujor

    Maujor Peon

    Messages:
    30
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use the HTML attribute acesskey
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Use of acesskey</title>
    </head>
    <body>
    <form>
    <select name="">
    <option acesskey="i" selected="selected">(I)ndia</option>
    <option acesskey="u">(U)S</option>
    <option acesskey="w">(S)witzerland</option>
    <option acesskey="a">(A)ustralia</option>
    </select>
    </form>
    </body>
    </html>
    Code (markup):
     
    Maujor, Feb 22, 2007 IP
    toughguy likes this.
  3. toughguy

    toughguy Well-Known Member

    Messages:
    846
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    118
    #3
    Hi Maujor,

    Thanks a lot..

    But the <option> doesn't seem to have accesskey attribute..

    The following elements support the accesskey attribute: A, AREA, BUTTON, INPUT, LABEL, and LEGEND, and TEXTAREA.

    Added rep for your help..

    Regards,
     
    toughguy, Feb 22, 2007 IP
  4. Maujor

    Maujor Peon

    Messages:
    30
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You are right. Sorry!
    The attribute that assigns keyboard shortcuts to HTML elements is ACCESSKEY, but I didn't check which elements support it. So, my fault :-(
    It seems that there isn't a way to achieve what you are intend via HTML markup.

    Further reading: http://www.w3.org/TR/REC-html40/index/attributes.html
     
    Maujor, Feb 23, 2007 IP