[Toolkit.Input] Fixed memory garbage generation while checking button states (#497).