Not tested, but this one should also work:

    i, j = np.nonzero(distance > threshold)
    return keypoints1[i], keypoints2[j]