There is no way to design such a system that is not cheatable. At the very least, someone could simply type out text from another window or device. On any normal operating system or browser, the user will be able to bypass whatever mechanism you have in place anyway.