Ace4896 / typetest

An offline typing test, written using Rust and Iced.
MIT License
32 stars 2 forks source link

Wayland support? #3

Open argenkiwi opened 3 months ago

argenkiwi commented 3 months ago

Nice project! I came across a post on Reddit about this project, installed it but got a error on KDE Wayland. I switched to X11 and all works well!

I really like the Monkeytype-like experience. Would it also be possible to capture some keystroke stats? I am trying to find a tool that calculates average and maximum dwell (or key-hold) time but I haven't found any good ones.

Ace4896 commented 3 months ago

Hey there, thanks for giving it a try! I haven't tried it on Wayland myself, but I imagine the 3 year old versions(!) of iced, winit etc. are causing issues. I've made some attempts to update it in the past, but never managed to finish it...

Keystroke stats would be nice to have - it was something I was heading towards for plotting graphs (like WPM/CPM over time). I've made #5 to keep track of it.

I can't guarantee anything in the near future since I'm busy with other projects and I haven't used Iced in a while, but I hope this answers your questions.

argenkiwi commented 3 months ago

Thanks for a quick response. I can see the project is a few years old and I don't expect you to jump into it and fix it immediately. I just wanted to express interest in case it was just a matter of updating some dependencies.

Regarding keystroke metrics, do you recall if you were able to capture key down and key up events when you implemented this application? I'm trying to gauge how feasible it would be to measure dwell/key-hold time using Rust. Thanks.


From: Jon Pacheco @.> Sent: Saturday, May 25, 2024 5:00:25 AM To: Ace4896/typetest @.> Cc: Leandro @.>; Author @.> Subject: Re: [Ace4896/typetest] Wayland support? (Issue #3)

Hey there, thanks for giving it a try! I haven't tried it on Wayland myself, but I imagine the 3 year old versions(!) of iced, winit etc. are causing issues. I've made some attempts to update it in the past, but never managed to finish it...

Keystroke stats would be nice to have - it was something I was heading towards for plotting graphs (like WPM/CPM over time). I've made #5https://github.com/Ace4896/typetest/issues/5 to keep track of it.

I can't guarantee anything in the near future since I'm busy with other projects and I haven't used Iced in a while, but I hope this answers your questions.

— Reply to this email directly, view it on GitHubhttps://github.com/Ace4896/typetest/issues/3#issuecomment-2130000696, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABVXPICLHILEUAQRWOPLUDDZD5W2TAVCNFSM6AAAAABIGWVVZ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZQGAYDANRZGY. You are receiving this because you authored the thread.Message ID: @.***>

Ace4896 commented 3 months ago

For Iced, you'll want to listen for iced::keyboard::Event messages to get key press/release information. There's no timestamp in the event itself, but you could augment it with the current timestamp in the handler for calculating key-hold time later on.

In the typing test widget, I intercepted these events for hotkeys, word submission and to prevent event propagation. When a hotkey or word is submitted, a different message type is returned - you could return a message type that includes the key press/release information when it's not a hotkey. There's new APIs for custom widgets now, but the overall approach would be the same.

For global keyboard events, Iced seems to have new functions for creating subscriptions that listen to them. You could also use the approach from the events example, though you'd have to filter out non-keyboard events.