firefox accesskey 配置

firefox 2.0 與 Access Key

應該有包括我在內的很多人有鍵盤快捷的習慣,在 Web 中,只要定義了 Access Key 的事件都可以用鍵盤快捷來進行觸發。這話如果有點抽象,舉一些實例你就很容易明白:比如大部分論壇你寫完稿要提交時,你可以不用再把手移至鼠標去點擊 submit 按鈕,而直接用 alt+s(有的是 alt+enter)來完成。在這裏,s 就是定義好的 Access Key。在 wordpress 的後臺撰寫中,所有的 quicktags 都有鍵盤快捷的 access key,以我自己爲例,一般習慣先在純文本編輯器上完成文字撰寫後,再 copy 至 wordpress 後臺撰寫的文本框內,很多時候,這些文本需要格式來裝飾,就需要添加 html tag,我的習慣是全部用鍵盤來完成,比如選定一段文字按 alt+l 就爲這段文字添加了嵌套好的 <li> 標籤; alt+a 就添加一個鏈接 <a> 。

而當我們安裝了 Firefox 2.0 後會發現,alt+(access key)觸發的不再是內容快捷而成了瀏覽器菜單快捷。這是 Firefox 的 Bug 還是它有意爲之?我試圖搜索一些官方資料來證明。

先來看看 W3C 對 Access Key 的官方描述:

The invocation of access keys depends on the underlying system. For instance, on machines running MS Windows, one generally has to press the “alt” key in addition to the access key. On Apple systems, one generally has to press the “ctrl” key in addition to the access key.

The rendering of access keys depends on the user agent. We recommend that authors include the access key in label text or wherever the access key is to apply. User agents should render the value of an access key in such a way as to emphasize its role and to distinguish it from other characters (e.g., by underlining it).

很清楚,觸發 Access Key 是使用 Alt 還是其它鍵取決於 user agent,除 MacOS 的 safafi 外,一般都習慣分配 alt 鍵。

弄明白這個我們便可以去 Mozillazine 找到答案,看看 Firefox 2.0 中是如何定義的: firefox 地址欄鍵入 about:config,filter 鍵入 ui.key.contentAccess,儘管上面給出的 mozillazine 頁面對各整數值的解釋不全,可我們還是在 mozillazine forum 找到了完整的定義:

* 1 = Shift
* 2 = Ctrl
* 3 = Shift + Ctrl
* 4 = Alt
* 5 = Shift + Alt
* 6 = Alt + Ctrl
* 7 = Ctrl + Shift + Alt

解決方案

可以看到,Firefox 2.0 的 Ui.key.contentAccess 默認值是 5,說明官方將 AccessKey 的觸發鍵改爲了 shift+alt,並非新版本的 Bug,那解決的方法就很簡單了(二選一):

1. 改變你的習慣,換用 shift+alt
2. 將整數值改回 4
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章