Skip to content

Commit

Permalink
Allow up or down for second argument.
Browse files Browse the repository at this point in the history
  • Loading branch information
octalmage committed Oct 12, 2015
1 parent 5e81b63 commit 718c822
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/robotjs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ NAN_METHOD(keyToggle)

v8::String::Utf8Value kstr(info[0]->ToString());
v8::String::Utf8Value fstr(info[2]->ToString());
down = info[1]->BooleanValue();
k = *kstr;
f = *fstr;

Expand All @@ -499,6 +498,28 @@ NAN_METHOD(keyToggle)
default:
return Nan::ThrowError("Invalid number of arguments.");
}

//Get down value if provided.
if (info.Length() > 1)
{
char *d;

Nan::Utf8String dstr(info[1]);
d = *dstr;

if (strcmp(d, "down") == 0)
{
down = true;
}
else if (strcmp(d, "up") == 0)
{
down = false;
}
else
{
return Nan::ThrowError("Invalid mouse button state specified.");
}
}

if (f)
{
Expand Down

0 comments on commit 718c822

Please sign in to comment.