Currently, I’m only using the ‘disable’ ko binding to disable the form button and input field once a form is submitted, but most of the adding will be done with the enter key. I noticed that if I press the enter key multiple times, the adding function will fire each time.
Is there any way to detect the keypress inside the adding function in the viewmodel? Or any other way of fixing this inside KO without resorting to jQuery?
You could add a flag to your viem model that will indicate form state and prohibit to submit second time:
Here is a fiddle: http://jsfiddle.net/JMLbV/