Skip to content

Instantly share code, notes, and snippets.

@MightyPork
MightyPork / usb_hid_keys.h
Last active March 31, 2025 21:42
USB HID Keyboard scan codes
/**
* USB HID Keyboard scan codes as per USB spec 1.11
* plus some additional codes
*
* Created by MightyPork, 2016
* Public domain
*
* Adapted from:
* https://source.android.com/devices/input/keyboard-devices.html
*/
var scrollPosition = sessionStorage.getItem("scrollPosition")
if(scrollPosition) window.scrollTo(0, scrollPosition)
document.addEventListener("scroll", function() {
sessionStorage.setItem("scrollPosition", window.pageYOffset | document.body.scrollTop)
})