Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> HTML

สร้าง Shortcut Key เปิดใช้งานองค์ประกอบใน HTML


ใช้แอตทริบิวต์ accesskey เพื่อสร้างปุ่มลัด (shortcut key) สำหรับองค์ประกอบ

ตัวอย่าง: Shortcut สำหรับลิงก์ Hadoop Tutorial

<!DOCTYPE html> <html>    <body>       <a href="https://www.tutorialspoint.com/hadoop/index.htm" accesskey="h">Hadoop Tutorial</a>       <p>กด ALT+SHIFT+H เพื่อเข้าถึง Hadoop Tutorial (Firefox Windows)</p>    </body> </html>

การกดปุ่มลัดในเบราว์เซอร์ต่างๆ

  • Windows/Linux: Chrome/Edge: Alt + Key | Firefox: Alt + Shift + Key
  • Mac: Chrome/Firefox/Safari: Ctrl + Opt + Key

ควรระบุปุ่มลัดใน UI ให้ผู้ใช้ทราบ และหลีกเลี่ยงการชนกับ shortcut ของเบราว์เซอร์/ระบบปฏิบัติการ