Data binding with keydown
I want to create a js MVVM framework


Oh no... not again. No, seriously. If this is for learning purposes or personal stuff, that's fine. If you plan to use this in real projects and production, you might consider picking up an existing framework or help improve an existing one. 


  my problem is input update always late, not like angular every type will update model.


That's because during a keydown event, the value of the input hasn't been changed yet. Frameworks usually use a combination of different events (which differ across elements as well as browsers) to consistently get values whenever the UI state changes. For instance, radio buttons in older IE don't fire some event on selection (I think it was change) and frameworks work around it by detecting click instead.


  angular every type will update model


The approach of each framework is different. Angular uses "dirty checking", which is a periodic check of data changes, and re-rendering once necessary. Frameworks like Ember and Backbone rely on setters which, aside from setting values, recompute dependent entities like computed props, and the DOM.

var elems = document.getElementsByTagName('*');
for (var ii = 0; ii &lt; elems.length; ii++) {
  if (elems[ii].getAttribute('mk')) {


This is a bad idea. It's fast in small cases, terrible when your page is huge. Consider narrowing down the initial set of elements instead of getting every single one of them and filtering.

&lt;input type="text" mk="value=test" value="test" /&gt;


Your markup is also... too much. All we needed is to know where this input binds to. You'd only need to assign the binding. Additionally, when using frameworks, you seldom actually touch the values. Values come straight from the view-model. In this case, "test" shouldn't be necessary. The following should be fine:

&lt;input type="text" data-mk="test" /&gt;


You should also consider when your data starts to contain objects and arrays. You'd then have to deal with data contexts, key path resolution, parsing the expressions, scoping. Your example works fine when your DOM only has one model to bind to. In real life, you could have a dozen of data sources and elements nesting each other.

elems[ii].onkeydown = function (e) {
    e = e || window.event;
    var charCode = e.charCode || e.keyCode,
        character = String.fromCharCode(charCode),
        value = this.value;

    var cmk = this.getAttribute('mk').split(';');
    for (var cc = 0; cc &lt; cmk.length; cc++) {
        var dd = cmk[cc].split('=');
        Mark.set(dd[1], value);
    }
}


Like I said earlier, listening to events require combinations of events and may differ across elements and browsers. You could move this logic out of your main framework logic (maybe in a separate function, or an entirely separate module) that you could simply pull in and call.