This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Quick Start Windows
Daniel edited this page Jan 4, 2020
·
2 revisions
To receive input you need to create a instance of the InputSource
class.
For receiving keyboard events you need to implement the IKeyboardEventReceiver
interface and pass it into the InputSource
constructor. When a keyboard event occurs the Receive
method is called in your class.
To be able to receive mouse events you need to implement the IMouseEventReceiver
interface and pass it into the InputSource
constructor. When a mouse event occurs the Receive
method is called in your class.
internal class MyKeyboardEventReceiver : IKeyboardEventReceiver
{
public void Receive(KeyboardEvent @event)
{
Console.WriteLine(@event.Key);
}
}
internal class MyMouseEventReceiver : IMouseEventReceiver
{
public void Receive(MouseEvent @event)
{
Console.WriteLine(@event.Key);
}
}
class Proram
{
static void Main()
{
var keyboardReceiver = new MyKeyboardEventReceiver();
var mouseReceiver = new MyMouseEventReceiver();
var inputSource = new InputSource(keyboardReceiver, mouseReceiver);
// Starts listening for input
inputSource.Listen();
Console.ReadLine();
}
}