Exemplo n.º 1
0
        protected override void HandleKeyPress(object sender, osuTK.KeyPressEventArgs e)
        {
            // Drop any keypresses if the control, alt, or windows/command key are being held.
            // This is a workaround for an issue on macOS where osuTK will fire KeyPress events even
            // if modifier keys are held.  This can be reverted when it is fixed on osuTK's side.
            var state = osuTK.Input.Keyboard.GetState();

            if (state.IsKeyDown(osuTK.Input.Key.LControl) ||
                state.IsKeyDown(osuTK.Input.Key.RControl) ||
                state.IsKeyDown(osuTK.Input.Key.LAlt) ||
                state.IsKeyDown(osuTK.Input.Key.RAlt) ||
                state.IsKeyDown(osuTK.Input.Key.LWin) ||
                state.IsKeyDown(osuTK.Input.Key.RWin))
            {
                return;
            }

            // arbitrary choice here, but it caters for any non-printable keys on an A1243 Apple Keyboard
            if (e.KeyChar > 63000)
            {
                return;
            }

            // capslock is not correctly handled by osuTK, so force uppercase if capslock is on
            if (isCapsLockOn)
            {
                e = new osuTK.KeyPressEventArgs(char.ToUpper(e.KeyChar));
            }

            base.HandleKeyPress(sender, e);
        }
Exemplo n.º 2
0
        private void window_KeyPress(object sender, osuTK.KeyPressEventArgs e)
        {
            // Drop any keypresses if the control, alt, or windows/command key are being held.
            // This is a workaround for an issue on macOS where osuTK will fire KeyPress events even
            // if modifier keys are held.  This can be reverted when it is fixed on osuTK's side.
            if (RuntimeInfo.OS == RuntimeInfo.Platform.MacOsx)
            {
                var state = osuTK.Input.Keyboard.GetState();
                if (state.IsKeyDown(osuTK.Input.Key.LControl) ||
                    state.IsKeyDown(osuTK.Input.Key.RControl) ||
                    state.IsKeyDown(osuTK.Input.Key.LAlt) ||
                    state.IsKeyDown(osuTK.Input.Key.RAlt) ||
                    state.IsKeyDown(osuTK.Input.Key.LWin) ||
                    state.IsKeyDown(osuTK.Input.Key.RWin))
                {
                    return;
                }
                // arbitrary choice here, but it caters for any non-printable keys on an A1243 Apple Keyboard
                if (e.KeyChar > 63000)
                {
                    return;
                }
            }

            pending += e.KeyChar;
        }
Exemplo n.º 3
0
 protected virtual void HandleKeyPress(object sender, osuTK.KeyPressEventArgs e) => pending += e.KeyChar;