Beispiel #1
0
        public IInputManager RegisterKeyHandler(ConsoleKey key, AsyncKeyPressHandler handler)
        {
            if (!_handlers.TryGetValue(key, out Dictionary <ConsoleModifiers, AsyncKeyPressHandler> handlers))
            {
                _handlers[key] = handlers = new Dictionary <ConsoleModifiers, AsyncKeyPressHandler>();
            }

            if (handler == null)
            {
                handlers.Remove(default);
Beispiel #2
0
        public IInputManager RegisterKeyHandler(ConsoleKey key, ConsoleModifiers modifiers, AsyncKeyPressHandler handler)
        {
            if (!_handlers.TryGetValue(key, out Dictionary <ConsoleModifiers, AsyncKeyPressHandler> handlers))
            {
                _handlers[key] = handlers = new Dictionary <ConsoleModifiers, AsyncKeyPressHandler>();
            }

            if (handler == null)
            {
                handlers.Remove(modifiers);
            }
            else
            {
                handlers[modifiers] = handler;
            }

            return(this);
        }