Я должен посоветовать вам против этого типа редактирования ввода, так как это обычно расстраивает, когда вам нужно редактировать опечатки.
Также я не имею представления о проблемах, связанных с доступностью.
Шаблон ввода проверяет только данные при отправке, поэтому это не то, что вы ищете.
Тем не менее, вот одно из возможных решений в JS:
// select the input element
var i = document.querySelector('input.hyphen');
// number of charatcers before the hyphen
var n = 4;
// run this function everytime the user release a key
i.addEventListener('keyup', function (event) {
// text cleared of all dashes
var t = i.value.replace(/-/g, '');
// save the carret position
var s = i.selectionStart;
// beguining string with n digits
var b = t.substr(0, n);
// end string with what's left (maxLength)
var e = t.substr(n);
// if there are more then n digits
if (e.length) {
// join then with a dash
i.value = [b, e].join('-');
// if the caret was before the dash put it back to the saved position
if (s <= n) i.setSelectionRange(s, s);
// if the caret was next to the dash put it after
if (s == n+1) i.setSelectionRange(s+1, s+1);
// if there's no end string then no need for dashes, just show the beguining
} else i.value = b;
});
<input class="hyphen" placeholder="0000-0000000" maxlength="12">