keyup 鍵盤事件 - 偵測是否按下特定鍵盤
觸發時機
當你按下特定鍵盤又放開的那刻就會被觸發。
使用方式
HTML:
JavaScript:
const input = document.querySelector('input');
input.addEventListener("keyup", function (e) {
console.log(e);
});
檢查:console.log(e)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
可以知道:
當按下 r
, key='r'
,可以利用鍵盤按鍵去執行需要觸發的事件。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
keyup 配合 .key
找到特定鍵盤按鍵觸發事件
codepen:
最後,親愛的大家!我需要你的大聲鼓勵 ٩(⚙ᴗ⚙)۶
如果覺得這篇文章對你有幫助,請給我個一個小小的鼓勵 ❤ 讓我知道,這會成為我寫下去很大的動力。
對了,我還有其他文章,如果有興趣也來逛逛吧!
(文章中如有覺得不妥之處、錯誤內容,也可以透過聯絡我,我會儘速改善,感謝!)
☞ YoJanni 珍妮 2021 正在設計轉職前端的路上,希望大家在學習的路上能夠一起成長
☞ 聯絡我