Which language are you using?
Essentially, you want to measure distance between any two joints. In javascript, it might look something like this pseudocode:
var delta = Leap.vec3.create()
Leap.vec3.sub(delta, hand.thumb.distal.nextJoint, hand.middleFinger.proximal.nextJoint);
var distance = Leap.vec3.length(delta);
if (distance < 30) // mm...