Fix crash when pressing Enter key in formspec menu

An attempt to fix #1012