public boolean isActive()
    {
        boolean isDown = medium.isButtonDown( getButton() ); // is the key being pressed right now?
        boolean preMask = false; // would the keybinding be active without the key mask?
        boolean active = false; // is the keybinding active after the key mask?

        switch ( getMode() )
        {

            case BUTTON_DOWN:
                preMask = isDown;
                break;

            case BUTTON_UP:
                preMask = !isDown;
                break;

            case BUTTON_PRESSED:
                preMask = !lastDown && isDown;
                break;

            case BUTTON_RELEASED:
                preMask = lastDown && !isDown;
                break;

        }

        active = preMask && Input.isMaskActive( getMask() );

        lastDown = isDown;
        return active;
    }