// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; using osu.Framework.Extensions.TypeExtensions; using osu.Framework.Input.States; using osuTK.Input; namespace osu.Framework.Input.Events { /// /// Events of a keyboard key. /// public abstract class KeyboardEvent : UIEvent { public readonly Key Key; /// /// Whether a specific key is pressed. /// public bool IsPressed(Key key) => CurrentState.Keyboard.Keys.IsPressed(key); /// /// Whether any key is pressed. /// public bool HasAnyKeyPressed => CurrentState.Keyboard.Keys.HasAnyButtonPressed; /// /// List of currently pressed keys. /// public IEnumerable PressedKeys => CurrentState.Keyboard.Keys; protected KeyboardEvent(InputState state, Key key) : base(state) { Key = key; } public override string ToString() => $"{GetType().ReadableName()}({Key})"; } }