I have a simple application with an input field that should insert a predefined piece of text as you type.
The code I have looks like this:
Ok, this is a bit dirty tricky: remove the last char to override user input key:
// ...
private int _petitionCharStep = 0;
private string _petition = "This is a dummy text";
public string PetitionInput { get; set; } = string.Empty;
void PetitionHandleKeyDown(UIKeyboardEventArgs arg) {
if (_petitionCharStep >= _petition.Length )
{
PetitionInput = _petition.Substring(0, _petition.Length-1 );
_petitionCharStep--;
}
}
void PetitionHandleKeyUp(UIKeyboardEventArgs arg) {
if (_petitionCharStep < _petition.Length )
{
PetitionInput += _petition[_petitionCharStep];
_petitionCharStep++;
}
}
Test it at blazorfiddle.