Fixed gui and key event works correctly