问题描述:

I'm using keyboard shortcuts on my website. It seems Firefox and Chrome use similar ones. What keyboard shortcuts are free on both browsers? For an example ALT + G, etc

网友答案:

The best way to find out, is to try it!

Note that each browser has it's own version of accesskeys (these are for Windows) See: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes for details.

  • Chrome: ALT + key
  • Firefox: ALT + SHIFT + key
  • Internet Explorer: ALT + key
  • Opera: SHIFT + ESC ... (dialog) (supposedly... but I can't get any to work)
  • Safari: ALT + key

Using the code below... here were my test results:

  • Firefox: All A-Z,0-9 keys are available
  • Chrome: A-C, _ , _ , _ ,G-Z, 0-9 (D focuses the location bar, E & F opens the "Hamburger" menu)
  • Internet Explorer: A-C, _ ,E-Z, 0-9 (D focuses the location bar)

This might be slightly different on Mac (I haven't tested yet)

<!doctype html>
<html>
 <head>
  <title>Access Key Test</title>
</head>
<body>
  <form name="test">
    <input type="button" value="A" accesskey="A" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="B" accesskey="B" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="C" accesskey="C" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="D" accesskey="D" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="E" accesskey="E" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="F" accesskey="F" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="G" accesskey="G" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="H" accesskey="H" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="I" accesskey="I" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="J" accesskey="J" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="K" accesskey="K" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="L" accesskey="L" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="M" accesskey="M" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="N" accesskey="N" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="O" accesskey="O" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="P" accesskey="P" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="Q" accesskey="Q" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="R" accesskey="R" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="S" accesskey="S" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="T" accesskey="T" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="U" accesskey="U" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="V" accesskey="V" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="W" accesskey="W" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="X" accesskey="X" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="Y" accesskey="Y" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="Z" accesskey="Z" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="0" accesskey="0" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="1" accesskey="1" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="2" accesskey="2" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="3" accesskey="3" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="4" accesskey="4" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="5" accesskey="5" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="6" accesskey="6" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="7" accesskey="7" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="8" accesskey="8" onclick="console.log(this.value);alert(this.value);"/>
    <input type="button" value="9" accesskey="9" onclick="console.log(this.value);alert(this.value);"/>
  </form>
</body>
</html>
相关阅读:
Top