본문 바로가기
프로그래밍/Xamarin(자마린)

[Xamarin] KeyDownEvent fires twice on Android

by 그래도동 2022. 8. 10.
728x90
반응형
 public override bool OnKeyDown([GeneratedEnum] Keycode keyCode, KeyEvent e)
{
    base.OnKeyDown(keyCode, e);

    // work

    return true;
}

// or

public override bool DispatchKeyEvent(KeyEvent e)
{
    base.DispatchKeyEvent(e);

    // work
    if (e.Action == KeyEventActions.Up)
    {
        KeyEventClass.CurrentHandler?.OnKeyUpEvent(e.ScanCode);
    }

    return true;
}

 

If you don't turn on the number lock, there are times when Android keydownevent comes in twice.
It is difficult to control the number lock, so you can return the event to true.

728x90
반응형

댓글