Masked input jquery why when you enter text using the event lost the mask?

There is a masked input plugin for Jquery https://github.com/RobinHerbots/jquery.inputmask

$("input[type=text]").mask("+7(999)-999-99-99"); // Bingham plugin to all input fields

on the screen there are buttons
<button data-num="1">1</button>
<button data-num="2">2</button>


$(document).ready(function(){
$("input[type=text]").mask("+7(999)-999-99-99"); 
$("button").click(function(){
$("input[type=text]").val($("input[type=text]").val() + $(this).data("num")); // get the field value and add figure button
})
});


when you press the button the value of the input changes but lost the mask, prompt where to dig.

P. S: next time problems I will pour on jsfiddle:)
September 26th 19 at 11:46
1 answer
September 26th 19 at 11:48
Solution
After all, You forced me to do an example. OK.
As I expected, the thing is that the plugin catches keyboard events and react to them. If You simply insert data nothing happens. Can try to insert Your sample and press Enter the plugin works again.
So here's an example, maybe not very beautiful, but the solutions after you push the button this code fires an event of pressing the enter key.
codepen.io/iiil/pen/BLtoq
Read carefully the documentation, it is taken into account, but I couldn't find. Maybe there is some refresh method.
You can also run the mask for a second time
codepen.io/iiil/pen/xnGhm
But this option is even worse.

Find more questions by tags JavaScriptjQuery