Unwanted keyboard input in the editor – ShiVa Engine

Unwanted keyboard input in the editor

If your game uses keyboard inputs, ShiVa may sometimes fire your keyboard event handlers right after you press the Play button. This may lead to unwanted behavior. Fortunately, this issue only occurs in the editor and not on exports.

You can prevent any unwanted input at the beginning of your game by adding this line of Lua code at the beginning of your onKeyboardKeyUp/Down handlers:

if ( system.getClientType ( ) == system.kClientTypeEditor and application.getTotalFrameTime ( ) < 1 ) then return end

This will block any keyboard input at the beginning of the game for one second, assuming you are in the editor. Naturally, you can adjust the number on the right to whatever time span you need.




Need more answers?

  • slackBanner