Skip to content

Commit 4722a4a

Browse files
committed
docs(device): add usage example
1 parent 89fbf6c commit 4722a4a

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

types/device.d.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,24 @@ function Device:read() end
247247
---@return string? err Error message on failure.
248248
function Device:flush() end
249249

250+
---
251+
---Query and monitor physical Linux input devices.
252+
---
253+
---```lua
254+
---local evdev = require "evdev"
255+
---
256+
----- Find and open the primary keyboard
257+
---local dev = assert(evdev.device.open("/dev/input/event0"))
258+
---print("Opened device: " .. dev.name)
259+
---
260+
----- Process events in a loop
261+
---for event in dev:events() do
262+
--- if evdev.events.is_press(event) then
263+
--- print("Key Pressed! Code: " .. event.code)
264+
--- end
265+
---end
266+
---```
267+
---
250268
---@class evdev.device
251269
local M = {}
252270

0 commit comments

Comments
 (0)