internal void SetKey(Key key, uint scancode, bool state)
{
if (keys[(int)key] != state || KeyRepeat)
{
keys[(int)key] = scancodes[scancode] = state;
if (state && KeyDown != null)
{
args.Key = key;
args.ScanCode = scancode;
KeyDown(this, args);
}
else if (!state && KeyUp != null)
{
args.Key = key;
args.ScanCode = scancode;
KeyUp(this, args);
}
}
}