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.
