I now understand what is going on:
The onchange event will be triggered before the onclick handler is performed :
1°) user is writing in the input field
2°) user clicks on the mini keyboard
3°) input field lose focus
4°) input field's onchange event is triggered
5°) mini keyboard has focus
6°) mini keyboard's onclick handler is performed
Which shows me you clearly understood the problem from the start.
Following up on your two suggestions, if I remove the onchange event handler, then how would I handle changes if the on screen keyboard is not used ?