本文介紹了jQuery 按鍵左/右導航的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我想讓我的內容滑塊能夠響應按鍵(左箭頭鍵和右箭頭鍵)功能.我讀過一些瀏覽器和操作系統之間的一些沖突.
I want to give my content slider the ability to respond to keypress (LEFT ARROW key and RIGHT ARROW key) feature. I have read about some conflicts between several browsers and operation systems.
用戶可以在全球網站(正文)上瀏覽內容.
The user can navigate the content while he is on the global website (body).
偽代碼:
ON Global Document
IF Key Press LEFT ARROW
THEN animate #showroom css 'left' -980px
IF Key Press RIGHT ARROW
THEN animate #showroom css 'left' +980px
我需要一個沒有任何交叉(瀏覽器、操作系統)沖突的解決方案.
I need a solution without any crossover (Browsers, OSs) conflicts.
推薦答案
$("body").keydown(function(e) {
if(e.keyCode == 37) { // left
$("#showroom").animate({
left: "-=980"
});
}
else if(e.keyCode == 39) { // right
$("#showroom").animate({
left: "+=980"
});
}
});
這篇關于jQuery 按鍵左/右導航的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!