Hi,
I am a beginner for Metro app development and trying to use the keydown event but not the keyup event with a text box element on the XAML. I have created two key event functions (up and down) from the text box, which are the below. The problem is the keydown function works only when the key is up but not down. If I hold the key press down, the event does not come out until the key up, which is the same as the keyup function.
I am working to get keyboard input from the touch softkeyboard. For example, after invoking the touch keyboard with the text box element, I like to play a unique sound only when a key (e.g., 'Q' or 'K') is pressed.
Anyone knows how to fix this problem? I also appreciate that you can help me know the alternative way with an example source code. Thank you a lot in advance.
MainPage::OnKeyUp(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
{
if((int)e->Key == 112) // F1 key
{
errorText->Text = "F1 Key up";
}
}
MainPage::OnKeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
{
if((int)e->Key == 112) // F1 key
{
errorText->Text = "F1 Key down";
}
}
I just found that only space key, backspace and enter key are working for keydown but all other keys are sending the key down event when the key is released on the touch keyboard. So my question must be rephrased to how to make all other keys send the keydown event on the Keydown api? or the other apis?
Thank you.
I am a beginner for Metro app development and trying to use the keydown event but not the keyup event with a text box element on the XAML. I have created two key event functions (up and down) from the text box, which are the below. The problem is the keydown function works only when the key is up but not down. If I hold the key press down, the event does not come out until the key up, which is the same as the keyup function.
I am working to get keyboard input from the touch softkeyboard. For example, after invoking the touch keyboard with the text box element, I like to play a unique sound only when a key (e.g., 'Q' or 'K') is pressed.
Anyone knows how to fix this problem? I also appreciate that you can help me know the alternative way with an example source code. Thank you a lot in advance.
MainPage::OnKeyUp(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
{
if((int)e->Key == 112) // F1 key
{
errorText->Text = "F1 Key up";
}
}
MainPage::OnKeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
{
if((int)e->Key == 112) // F1 key
{
errorText->Text = "F1 Key down";
}
}
I just found that only space key, backspace and enter key are working for keydown but all other keys are sending the key down event when the key is released on the touch keyboard. So my question must be rephrased to how to make all other keys send the keydown event on the Keydown api? or the other apis?
Thank you.