javascript and buttonpress on/off

  • Hi,

    i´m toying around with javascript and noticed, that the monome sends the button two times, one time on press and one time on release.
    if i call a function that has to increment a variable by one this gets annoying because one press on the monome calls the function twice.

    would be great to know how you guys deal with this, thanks!

    edit: it does that even if i get rid of the button state , at least that´s what i figure from looking at the max output window.

  • I do this in Max with a simple [if $i3 == 1 then $i1], so if its a note on, pass along which button.

  • in js i would use something like: (replace "prefix" with your apps prefix)

    function anything() {
    var args = arrayfromargs(messagename, arguments);

    if(args[0]=="/prefix/grid/key" && args[3]==1)
    {
    // your code
    }
    }

  • hi,
    thanks a lot for the code!