void UpdateKeyboardState() { // dont process if we have no focused text element if (_keyboardFocusElement == null) { return; } var currentPressedKeys = Input.CurrentKeyboardState.GetPressedKeys(); // keys down for (var i = 0; i < currentPressedKeys.Length; i++) { var key = currentPressedKeys[i]; if (!_lastPressedKeys.Contains(key)) { _keyboardFocusElement.KeyDown(key); // if alt isnt pressed we will call keyPressed if (!InputUtils.IsAltDown()) { var c = key.GetChar(); if (c.HasValue) { ClearKeyRepeatTimer(); _keyboardFocusElement.KeyPressed(key, c.Value); // if we dont have a control key pressed setup a repeat timer for the key if (!InputUtils.IsControlDown()) { _repeatKey = key; _keyRepeatTimer = Core.Schedule(_keyRepeatTime, true, this, t => { var self = t.Context as Stage; if (self._keyboardFocusElement != null) { self._keyboardFocusElement.KeyPressed(_repeatKey, _repeatKey.GetChar().Value); } }); } } } } } // keys released for (var i = 0; i < _lastPressedKeys.Length; i++) { var key = _lastPressedKeys[i]; if (!currentPressedKeys.Contains(key)) { _keyboardFocusElement.KeyReleased(key); ClearKeyRepeatTimer(); } } _lastPressedKeys = currentPressedKeys; }