05-08-26
Key Press and Scroll Event Logger
This Lua script logs all key presses, releases, and scroll wheel events to the Rebind logs. It's a useful tool for debugging hardware input and understanding how your keys are being used.
Question
Create a Rebind Lua script that logs key presses and releases to the terminal.
Rebind AI
-- rebind: name=Key Logger
function OnDown(key)
print("KEY DOWN: " .. key)
return true
end
function OnUp(key, duration)
print("KEY UP: " .. key .. " (held " .. duration .. "ms)")
return true
endThis script logs every key press and release to the Rebind logs tab. The OnDown hook fires when a key is pressed and shows the key name. The OnUp hook fires when it's released and shows how long it was held in milliseconds.
All output appears in the Rebind UI Logs tab. print() is an alias for Log.Info() — both work the same way.
If you want to see mouse buttons and scroll events too, you can add:
function OnScroll(delta)
print("SCROLL: " .. delta)
return true
endQuestion
Provide the complete script in a single copy-and-paste block.
Rebind AI
-- rebind: name=Key Logger
function OnDown(key)
print("KEY DOWN: " .. key)
return true
end
function OnUp(key, duration)
print("KEY UP: " .. key .. " (held " .. duration .. "ms)")
return true
end
function OnScroll(delta)
print("SCROLL: " .. delta)
return true
endCopy this entire script into a new module in the Rebind UI. It logs all key presses, releases (with hold duration), and scroll events to the Logs tab.