Jump to content

Detect If The User Release Keypress In Control


joniveehernandez
 Share

You are about to reply to a thread that has been inactive for 1391 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

In the code snippet that Ron posted, the "end" variable will contain a bit vector identifying which key was released in this event, and "held" will be a bit vector of keys still pressed. If held == 0, they've all been released.

[EDIT: Not quite. In theory, a single event could hold both a key being released (end != 0) and another one being pressed (start !=0), in which case held could be 0 but a new key is pressed. Rather, I should have said that all keys being released corresponds to the even simpler condition of level == 0.]

Link to comment
Share on other sites

  • 3 years later...

Control events are sometimes hard to keep track of.   I use this template from the old LSL Wiki to help me understand what's going on:

control(key id, integer held, integer change) {
        integer pressed = held & change;
        integer down = held & ~change;
        integer released = ~held & change;
        integer inactive = ~held & ~change;
    }

So if I want to detect when I release the left arrow key, it would be:


control(key id, integer held, integer change) {
        integer pressed = held & change;
        integer down = held & ~change;
        integer released = ~held & change;
        integer inactive = ~held & ~change;

        if (released & CONTROL_ROT_LEFT){
        	llOwnerSay("Released left arrow key.");
        }
    }

 

 

  • Like 2
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1391 days.

Please take a moment to consider if this thread is worth bumping.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...