Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Quick Start Windows

Daniel edited this page Jan 4, 2020 · 2 revisions

Receiving input

To receive input you need to create a instance of the InputSource class.

Implementing a keyboard event receiver

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.

Implementing a mouse event receiver

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.

Code

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();
    }
}

Windows

Quick Start

Linux

Quick Start

Clone this wiki locally