Neptune-Crypto / neptune-core

anonymous peer-to-peer cash
Apache License 2.0
23 stars 7 forks source link

dashboard detecting spurious key events on windows #65

Open jan-ferdinand opened 9 months ago

jan-ferdinand commented 9 months ago

If I remember correctly, and without access to a machine to test this on, there are spurious key events registered when the dashboard is run on windows. According to this:

[You] might use the following code for sending key presses:

 CrosstermEvent::Key(e) => tx.send(Event::Key(e)),

However, on Windows, when using Crossterm, this will send the same Event::Key(e) twice; one for when you press the key, i.e. KeyEventKind::Press and one for when you release the key, i.e. KeyEventKind::Release. On MacOS and Linux only KeyEventKind::Press kinds of key event is generated.

To make the code work as expected across all platforms, you can do this instead:

 CrosstermEvent::Key(key) => {
   if key.kind == KeyEventKind::Press {
     event_tx.send(Event::Key(key)).unwrap();
   }
 },

This might help alleviate the issue.

dan-da commented 9 months ago

Nice catch. I will have a look.