예제 #1
0
        /*
         * Take the text value of the key and set the textbox text.
         */
        private void txtBrakeKey_KeyDown(object sender, KeyEventArgs e)
        {
            VirtualKeyCode newKey = KeyMap.LookupVKey(e.Key);

            txtBrakeKey.Text = e.Key.ToString();
            this.ss.SetBrakeKey(newKey);
        }
예제 #2
0
        /*
         * This method checks the passed in key to see if it is invalid. If it invalid, true is returned. Otherwise, false is returned.
         * The PreviewKeyDown events will set e.Handled to the returned value to filter out invalid key strokes.
         */
        private bool FilterKey(System.Windows.Input.Key pressedKey)
        {
            bool invalid = false;

            // If the key was not found and is equal to 0, ignore the event
            if (KeyMap.LookupVKey(pressedKey) == 0)
            {
                invalid = true;
            }

            // If the key is invalid, ignore the event (handled = true)
            if (!KeyMap.CheckKey(pressedKey))
            {
                Console.WriteLine("ignored");
                invalid = true;
            }

            return(invalid);
        }