KeyTapGestureΒΆ

Methods:

class com::leapmotion::leap::KeyTapGesture

The KeyTapGesture class represents a tapping gesture by a finger or tool.

A key tap gesture is recognized when the tip of a finger rotates down toward the palm and then springs back to approximately the original position, as if tapping. The tapping finger must pause briefly before beginning the tap.

api/../../../images/Leap_Gesture_Tap.png

Important: To use key tap gestures in your application, you must enable recognition of the key tap gesture. You can enable recognition with:

controller.enableGesture(Gesture.Type.TYPE_KEY_TAP);

Key tap gestures are discrete. The KeyTapGesture object representing a tap always has the state, STATE_STOP. Only one KeyTapGesture object is created for each key tap gesture recognized.

You can set the minimum finger movement and velocity required for a movement to be recognized as a key tap as well as adjust the detection window for evaluating the movement using the config attribute of a connected Controller object. Use the following configuration keys to configure key tap recognition:

Key string Value type Default value Units
Gesture.KeyTap.MinDownVelocity float 50 mm/s
Gesture.KeyTap.HistorySeconds float 0.1 s
Gesture.KeyTap.MinDistance float 3.0 mm

The following example demonstrates how to set the key tap configuration parameters:

controller.config().setFloat("Gesture.KeyTap.MinDownVelocity", 40.0f);
controller.config().setFloat("Gesture.KeyTap.HistorySeconds", .2f);
controller.config().setFloat("Gesture.KeyTap.MinDistance", 1.0f);
controller.config().save();

The Controller object must be connected to the Leap Motion service/daemon before setting the configuration parameters.

Since
1.0

Public Functions

Vector direction()

The direction of finger tip motion.

Vector tapDirection = keytap.direction();

Return
Vector A unit direction vector if the finger tip is moving; otherwise, a zero-vector.
Since
1.0

KeyTapGesture()

Constructs a new KeyTapGesture object.

An uninitialized KeyTapGesture object is considered invalid. Get valid instances of the KeyTapGesture class from a Frame object.

Since
1.0

KeyTapGesture(Gesture rhs)

Constructs a KeyTapGesture object from an instance of the Gesture class.

if(gesture.type() == KeyTapGesture.classType()) {
    KeyTapGesture keytapGesture = new KeyTapGesture(gesture);
}

Since
1.0
Parameters

Pointable pointable()

The finger performing the key tap gesture.

Pointable tappingPointable = keytap.pointable();

Return
Pointable A Pointable object representing the tapping finger.
Since
1.0

Vector position()

The position where the key tap is registered.

Vector tapPosition = keytap.position();

Return
Vector A Vector containing the coordinates of tap location.
Since
1.0

float progress()

The progress value is always 1.0 for a key tap gesture.

Return
float The value 1.0.
Since
1.0

Public Static Functions

Gesture.Type classType()

The key tap gesture type.

if(gesture.type() == KeyTapGesture.classType()) {
    KeyTapGesture keytapGesture = new KeyTapGesture(gesture);
}

Return
Type The type value designating a key tap gesture.
Since
1.0