Mouse.release()
描述
放開一個已被按下(請參考 Mouse.press())的鼠標按鍵。Mouse.release()
預設是鼠標左鍵。
注意:當你呼叫 Mouse.release()
函式後,86Duino 會接管你的鼠標,使它做出放開鼠標按鍵的行為(使用此函式前,請確認實體鼠標運作是沒問題的)。 建議你可以在程式中,判斷一個外接按鈕是否按下,來決定是否送出放開 86Duino 鼠標按鍵的命令。
語法
Mouse.release();
Mouse.release(button);
參數
button
:要放開哪一個按鍵 char 型別
-MOUSE_LEFT
(預設)
-MOUSE_RIGHT
-MOUSE_MIDDLE
回傳
無回傳值
範例
void setup(){ // 按下這個開關相當於按下鼠標按鍵 pinMode(2,INPUT); // 按下這個開關相當於放開鼠標按鍵 pinMode(3,INPUT); // 初始化 HID 鼠標函式庫 Mouse.begin(); } void loop(){ // 假如開關被按下了,就按下鼠標左鍵不放 if(digitalRead(2) == HIGH){ Mouse.press(); } // 假如開關被按下了,就放開鼠標左鍵 if(digitalRead(3) == HIGH){ Mouse.release(); } }
See also
- Mouse.begin()
- Mouse.click()
- Mouse.end()
- Mouse.move()
- Mouse.press()
- Mouse.isPressed()
The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.