How can I use adb to send a longpress key event?












9















I can use something like:



adb shell input keyevent 4


and this will send a single 'Back' button press to my device. How can I send a longpress?



Thanks










share|improve this question





























    9















    I can use something like:



    adb shell input keyevent 4


    and this will send a single 'Back' button press to my device. How can I send a longpress?



    Thanks










    share|improve this question



























      9












      9








      9


      7






      I can use something like:



      adb shell input keyevent 4


      and this will send a single 'Back' button press to my device. How can I send a longpress?



      Thanks










      share|improve this question
















      I can use something like:



      adb shell input keyevent 4


      and this will send a single 'Back' button press to my device. How can I send a longpress?



      Thanks







      android adb






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 27 '15 at 12:52







      whoabackoff

















      asked Jun 21 '12 at 16:42









      whoabackoffwhoabackoff

      97331329




      97331329
























          6 Answers
          6






          active

          oldest

          votes


















          20














          You can try this command:



          adb shell input touchscreen swipe 170 187 170 187 2000


          Your application position on screen is
          170, 187; delay time is 2000 (ms);



          Long press HOME key:



          adb shell sendevent /dev/input/event2 1 172 1
          adb shell sendevent /dev/input/event2 0 0 0
          timeout 1
          adb shell sendevent /dev/input/event2 1 172 0
          adb shell sendevent /dev/input/event2 0 0 0


          You can goto cmd and type adb shell getevent | find "event2" ; long press HOME key to see more.






          share|improve this answer





















          • 1





            Doesn't work for me at all. And when I use getevent I see event0 when pressing keys, not event2.

            – Tomáš Zato
            May 26 '16 at 11:53






          • 1





            what is the meaning of numbers like 0, 1, 172? Can you give me a link as a reference for knowing about these numbers and the way we should apply them

            – Bobs
            Sep 15 '16 at 4:47











          • Found this useful for long pressing power key forum.xda-developers.com/…

            – Adeel Ahmad
            Oct 17 '17 at 19:08



















          9














          Since this commit in Android 4.4 it is possibile to use:



          adb shell input keyevent --longpress KEYCODE_L


          This other commit further improved the behaviour.






          share|improve this answer

































            1














            When you want to delete something or repeat some Event or just input a lot of numbers, you can use code like the following. It will imitate a longpress on a keyboard:



            adb shell input keyevent KEYCODE_FORWARD_DEL KEYCODE_FORWARD_DEL KEYCODE_FORWARD_DEL //delete 3 times


            adb shell input keyevent KEYCODE_1 KEYCODE_1 KEYCODE_1 //input value '111'


            You can repeat the event or input things without limits, just like a Longpress on the key. It's the same thing. You can define your own longpass and times Now






            share|improve this answer


























            • This was the only thing that worked for me for reliably deleting a long string of text- thanks!

              – rbennell
              Sep 21 '18 at 9:15



















            0














            This link discusses a similar problem, but the device in question (a Nexus One device)has the menu/home/back/search buttons as part of the touchscreen, not physical keys.



            This other one appears to be more inline with injecting a physical key input, but requires accessing the *.kl file for your devices driver to determine the device, type, key-code, value-press, and value-release codes for that specific device.



            However, the common link between the two appears to be



            adb shell sleep n


            , where n is the length (in seconds) of the press duration.



            Hopefully this might be of some use.






            share|improve this answer

































              -1














              Well, this developer link show the keycode is 128, which i already test, but no expected result



              You can check this link and this link. They show how to find it.






              share|improve this answer
























              • 128 is just the flag, not the actual keycode

                – whoabackoff
                Jun 21 '12 at 17:09













              • @whoabackoff anything happen if you send the OR of the flag and the keycode?

                – Chris Stratton
                Jun 21 '12 at 17:13











              • @chr the value of KEYCODE_BACK(4) OR FLAG_LONG_PRESS(128) is 132, which is just the value of KEYCODE_F2(132). This doesn't work.

                – whoabackoff
                Jun 21 '12 at 17:33



















              -1














              This might be too late to answer but surely will help others.



              Please use below cmd to achieve long press.



              adb shell input keyevent 5 sleep 5






              share|improve this answer



















              • 4





                This does not work.

                – arka.b
                Aug 27 '15 at 6:21











              • Please share problem statement I'll provide solution.

                – Arpana
                Aug 27 '15 at 11:46






              • 1





                Error: Invalid arguments for command: keyevent

                – Андрій Ковальчук
                Feb 22 '16 at 14:21











              • share your adb command

                – Arpana
                Feb 23 '16 at 5:26











              • adb shell input keyevent 5 ; sleep 5

                – DarkXDroid
                Mar 31 '17 at 8:38











              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f11142843%2fhow-can-i-use-adb-to-send-a-longpress-key-event%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              6 Answers
              6






              active

              oldest

              votes








              6 Answers
              6






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              20














              You can try this command:



              adb shell input touchscreen swipe 170 187 170 187 2000


              Your application position on screen is
              170, 187; delay time is 2000 (ms);



              Long press HOME key:



              adb shell sendevent /dev/input/event2 1 172 1
              adb shell sendevent /dev/input/event2 0 0 0
              timeout 1
              adb shell sendevent /dev/input/event2 1 172 0
              adb shell sendevent /dev/input/event2 0 0 0


              You can goto cmd and type adb shell getevent | find "event2" ; long press HOME key to see more.






              share|improve this answer





















              • 1





                Doesn't work for me at all. And when I use getevent I see event0 when pressing keys, not event2.

                – Tomáš Zato
                May 26 '16 at 11:53






              • 1





                what is the meaning of numbers like 0, 1, 172? Can you give me a link as a reference for knowing about these numbers and the way we should apply them

                – Bobs
                Sep 15 '16 at 4:47











              • Found this useful for long pressing power key forum.xda-developers.com/…

                – Adeel Ahmad
                Oct 17 '17 at 19:08
















              20














              You can try this command:



              adb shell input touchscreen swipe 170 187 170 187 2000


              Your application position on screen is
              170, 187; delay time is 2000 (ms);



              Long press HOME key:



              adb shell sendevent /dev/input/event2 1 172 1
              adb shell sendevent /dev/input/event2 0 0 0
              timeout 1
              adb shell sendevent /dev/input/event2 1 172 0
              adb shell sendevent /dev/input/event2 0 0 0


              You can goto cmd and type adb shell getevent | find "event2" ; long press HOME key to see more.






              share|improve this answer





















              • 1





                Doesn't work for me at all. And when I use getevent I see event0 when pressing keys, not event2.

                – Tomáš Zato
                May 26 '16 at 11:53






              • 1





                what is the meaning of numbers like 0, 1, 172? Can you give me a link as a reference for knowing about these numbers and the way we should apply them

                – Bobs
                Sep 15 '16 at 4:47











              • Found this useful for long pressing power key forum.xda-developers.com/…

                – Adeel Ahmad
                Oct 17 '17 at 19:08














              20












              20








              20







              You can try this command:



              adb shell input touchscreen swipe 170 187 170 187 2000


              Your application position on screen is
              170, 187; delay time is 2000 (ms);



              Long press HOME key:



              adb shell sendevent /dev/input/event2 1 172 1
              adb shell sendevent /dev/input/event2 0 0 0
              timeout 1
              adb shell sendevent /dev/input/event2 1 172 0
              adb shell sendevent /dev/input/event2 0 0 0


              You can goto cmd and type adb shell getevent | find "event2" ; long press HOME key to see more.






              share|improve this answer















              You can try this command:



              adb shell input touchscreen swipe 170 187 170 187 2000


              Your application position on screen is
              170, 187; delay time is 2000 (ms);



              Long press HOME key:



              adb shell sendevent /dev/input/event2 1 172 1
              adb shell sendevent /dev/input/event2 0 0 0
              timeout 1
              adb shell sendevent /dev/input/event2 1 172 0
              adb shell sendevent /dev/input/event2 0 0 0


              You can goto cmd and type adb shell getevent | find "event2" ; long press HOME key to see more.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited May 26 '16 at 12:05









              Tomáš Zato

              22.1k21114568




              22.1k21114568










              answered Dec 12 '13 at 7:25









              Nguyen Duc HanNguyen Duc Han

              23424




              23424








              • 1





                Doesn't work for me at all. And when I use getevent I see event0 when pressing keys, not event2.

                – Tomáš Zato
                May 26 '16 at 11:53






              • 1





                what is the meaning of numbers like 0, 1, 172? Can you give me a link as a reference for knowing about these numbers and the way we should apply them

                – Bobs
                Sep 15 '16 at 4:47











              • Found this useful for long pressing power key forum.xda-developers.com/…

                – Adeel Ahmad
                Oct 17 '17 at 19:08














              • 1





                Doesn't work for me at all. And when I use getevent I see event0 when pressing keys, not event2.

                – Tomáš Zato
                May 26 '16 at 11:53






              • 1





                what is the meaning of numbers like 0, 1, 172? Can you give me a link as a reference for knowing about these numbers and the way we should apply them

                – Bobs
                Sep 15 '16 at 4:47











              • Found this useful for long pressing power key forum.xda-developers.com/…

                – Adeel Ahmad
                Oct 17 '17 at 19:08








              1




              1





              Doesn't work for me at all. And when I use getevent I see event0 when pressing keys, not event2.

              – Tomáš Zato
              May 26 '16 at 11:53





              Doesn't work for me at all. And when I use getevent I see event0 when pressing keys, not event2.

              – Tomáš Zato
              May 26 '16 at 11:53




              1




              1





              what is the meaning of numbers like 0, 1, 172? Can you give me a link as a reference for knowing about these numbers and the way we should apply them

              – Bobs
              Sep 15 '16 at 4:47





              what is the meaning of numbers like 0, 1, 172? Can you give me a link as a reference for knowing about these numbers and the way we should apply them

              – Bobs
              Sep 15 '16 at 4:47













              Found this useful for long pressing power key forum.xda-developers.com/…

              – Adeel Ahmad
              Oct 17 '17 at 19:08





              Found this useful for long pressing power key forum.xda-developers.com/…

              – Adeel Ahmad
              Oct 17 '17 at 19:08













              9














              Since this commit in Android 4.4 it is possibile to use:



              adb shell input keyevent --longpress KEYCODE_L


              This other commit further improved the behaviour.






              share|improve this answer






























                9














                Since this commit in Android 4.4 it is possibile to use:



                adb shell input keyevent --longpress KEYCODE_L


                This other commit further improved the behaviour.






                share|improve this answer




























                  9












                  9








                  9







                  Since this commit in Android 4.4 it is possibile to use:



                  adb shell input keyevent --longpress KEYCODE_L


                  This other commit further improved the behaviour.






                  share|improve this answer















                  Since this commit in Android 4.4 it is possibile to use:



                  adb shell input keyevent --longpress KEYCODE_L


                  This other commit further improved the behaviour.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Feb 17 '15 at 20:28

























                  answered Dec 24 '14 at 1:00









                  Nick ChalkoNick Chalko

                  10913




                  10913























                      1














                      When you want to delete something or repeat some Event or just input a lot of numbers, you can use code like the following. It will imitate a longpress on a keyboard:



                      adb shell input keyevent KEYCODE_FORWARD_DEL KEYCODE_FORWARD_DEL KEYCODE_FORWARD_DEL //delete 3 times


                      adb shell input keyevent KEYCODE_1 KEYCODE_1 KEYCODE_1 //input value '111'


                      You can repeat the event or input things without limits, just like a Longpress on the key. It's the same thing. You can define your own longpass and times Now






                      share|improve this answer


























                      • This was the only thing that worked for me for reliably deleting a long string of text- thanks!

                        – rbennell
                        Sep 21 '18 at 9:15
















                      1














                      When you want to delete something or repeat some Event or just input a lot of numbers, you can use code like the following. It will imitate a longpress on a keyboard:



                      adb shell input keyevent KEYCODE_FORWARD_DEL KEYCODE_FORWARD_DEL KEYCODE_FORWARD_DEL //delete 3 times


                      adb shell input keyevent KEYCODE_1 KEYCODE_1 KEYCODE_1 //input value '111'


                      You can repeat the event or input things without limits, just like a Longpress on the key. It's the same thing. You can define your own longpass and times Now






                      share|improve this answer


























                      • This was the only thing that worked for me for reliably deleting a long string of text- thanks!

                        – rbennell
                        Sep 21 '18 at 9:15














                      1












                      1








                      1







                      When you want to delete something or repeat some Event or just input a lot of numbers, you can use code like the following. It will imitate a longpress on a keyboard:



                      adb shell input keyevent KEYCODE_FORWARD_DEL KEYCODE_FORWARD_DEL KEYCODE_FORWARD_DEL //delete 3 times


                      adb shell input keyevent KEYCODE_1 KEYCODE_1 KEYCODE_1 //input value '111'


                      You can repeat the event or input things without limits, just like a Longpress on the key. It's the same thing. You can define your own longpass and times Now






                      share|improve this answer















                      When you want to delete something or repeat some Event or just input a lot of numbers, you can use code like the following. It will imitate a longpress on a keyboard:



                      adb shell input keyevent KEYCODE_FORWARD_DEL KEYCODE_FORWARD_DEL KEYCODE_FORWARD_DEL //delete 3 times


                      adb shell input keyevent KEYCODE_1 KEYCODE_1 KEYCODE_1 //input value '111'


                      You can repeat the event or input things without limits, just like a Longpress on the key. It's the same thing. You can define your own longpass and times Now







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Jan 13 '17 at 18:24

























                      answered Jan 6 '17 at 20:15









                      OviOvi

                      193




                      193













                      • This was the only thing that worked for me for reliably deleting a long string of text- thanks!

                        – rbennell
                        Sep 21 '18 at 9:15



















                      • This was the only thing that worked for me for reliably deleting a long string of text- thanks!

                        – rbennell
                        Sep 21 '18 at 9:15

















                      This was the only thing that worked for me for reliably deleting a long string of text- thanks!

                      – rbennell
                      Sep 21 '18 at 9:15





                      This was the only thing that worked for me for reliably deleting a long string of text- thanks!

                      – rbennell
                      Sep 21 '18 at 9:15











                      0














                      This link discusses a similar problem, but the device in question (a Nexus One device)has the menu/home/back/search buttons as part of the touchscreen, not physical keys.



                      This other one appears to be more inline with injecting a physical key input, but requires accessing the *.kl file for your devices driver to determine the device, type, key-code, value-press, and value-release codes for that specific device.



                      However, the common link between the two appears to be



                      adb shell sleep n


                      , where n is the length (in seconds) of the press duration.



                      Hopefully this might be of some use.






                      share|improve this answer






























                        0














                        This link discusses a similar problem, but the device in question (a Nexus One device)has the menu/home/back/search buttons as part of the touchscreen, not physical keys.



                        This other one appears to be more inline with injecting a physical key input, but requires accessing the *.kl file for your devices driver to determine the device, type, key-code, value-press, and value-release codes for that specific device.



                        However, the common link between the two appears to be



                        adb shell sleep n


                        , where n is the length (in seconds) of the press duration.



                        Hopefully this might be of some use.






                        share|improve this answer




























                          0












                          0








                          0







                          This link discusses a similar problem, but the device in question (a Nexus One device)has the menu/home/back/search buttons as part of the touchscreen, not physical keys.



                          This other one appears to be more inline with injecting a physical key input, but requires accessing the *.kl file for your devices driver to determine the device, type, key-code, value-press, and value-release codes for that specific device.



                          However, the common link between the two appears to be



                          adb shell sleep n


                          , where n is the length (in seconds) of the press duration.



                          Hopefully this might be of some use.






                          share|improve this answer















                          This link discusses a similar problem, but the device in question (a Nexus One device)has the menu/home/back/search buttons as part of the touchscreen, not physical keys.



                          This other one appears to be more inline with injecting a physical key input, but requires accessing the *.kl file for your devices driver to determine the device, type, key-code, value-press, and value-release codes for that specific device.



                          However, the common link between the two appears to be



                          adb shell sleep n


                          , where n is the length (in seconds) of the press duration.



                          Hopefully this might be of some use.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Aug 27 '15 at 7:06









                          arka.b

                          151111




                          151111










                          answered Jun 21 '12 at 17:18









                          avoylesavoyles

                          5717




                          5717























                              -1














                              Well, this developer link show the keycode is 128, which i already test, but no expected result



                              You can check this link and this link. They show how to find it.






                              share|improve this answer
























                              • 128 is just the flag, not the actual keycode

                                – whoabackoff
                                Jun 21 '12 at 17:09













                              • @whoabackoff anything happen if you send the OR of the flag and the keycode?

                                – Chris Stratton
                                Jun 21 '12 at 17:13











                              • @chr the value of KEYCODE_BACK(4) OR FLAG_LONG_PRESS(128) is 132, which is just the value of KEYCODE_F2(132). This doesn't work.

                                – whoabackoff
                                Jun 21 '12 at 17:33
















                              -1














                              Well, this developer link show the keycode is 128, which i already test, but no expected result



                              You can check this link and this link. They show how to find it.






                              share|improve this answer
























                              • 128 is just the flag, not the actual keycode

                                – whoabackoff
                                Jun 21 '12 at 17:09













                              • @whoabackoff anything happen if you send the OR of the flag and the keycode?

                                – Chris Stratton
                                Jun 21 '12 at 17:13











                              • @chr the value of KEYCODE_BACK(4) OR FLAG_LONG_PRESS(128) is 132, which is just the value of KEYCODE_F2(132). This doesn't work.

                                – whoabackoff
                                Jun 21 '12 at 17:33














                              -1












                              -1








                              -1







                              Well, this developer link show the keycode is 128, which i already test, but no expected result



                              You can check this link and this link. They show how to find it.






                              share|improve this answer













                              Well, this developer link show the keycode is 128, which i already test, but no expected result



                              You can check this link and this link. They show how to find it.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Jun 21 '12 at 17:06









                              HeinHein

                              2,5471631




                              2,5471631













                              • 128 is just the flag, not the actual keycode

                                – whoabackoff
                                Jun 21 '12 at 17:09













                              • @whoabackoff anything happen if you send the OR of the flag and the keycode?

                                – Chris Stratton
                                Jun 21 '12 at 17:13











                              • @chr the value of KEYCODE_BACK(4) OR FLAG_LONG_PRESS(128) is 132, which is just the value of KEYCODE_F2(132). This doesn't work.

                                – whoabackoff
                                Jun 21 '12 at 17:33



















                              • 128 is just the flag, not the actual keycode

                                – whoabackoff
                                Jun 21 '12 at 17:09













                              • @whoabackoff anything happen if you send the OR of the flag and the keycode?

                                – Chris Stratton
                                Jun 21 '12 at 17:13











                              • @chr the value of KEYCODE_BACK(4) OR FLAG_LONG_PRESS(128) is 132, which is just the value of KEYCODE_F2(132). This doesn't work.

                                – whoabackoff
                                Jun 21 '12 at 17:33

















                              128 is just the flag, not the actual keycode

                              – whoabackoff
                              Jun 21 '12 at 17:09







                              128 is just the flag, not the actual keycode

                              – whoabackoff
                              Jun 21 '12 at 17:09















                              @whoabackoff anything happen if you send the OR of the flag and the keycode?

                              – Chris Stratton
                              Jun 21 '12 at 17:13





                              @whoabackoff anything happen if you send the OR of the flag and the keycode?

                              – Chris Stratton
                              Jun 21 '12 at 17:13













                              @chr the value of KEYCODE_BACK(4) OR FLAG_LONG_PRESS(128) is 132, which is just the value of KEYCODE_F2(132). This doesn't work.

                              – whoabackoff
                              Jun 21 '12 at 17:33





                              @chr the value of KEYCODE_BACK(4) OR FLAG_LONG_PRESS(128) is 132, which is just the value of KEYCODE_F2(132). This doesn't work.

                              – whoabackoff
                              Jun 21 '12 at 17:33











                              -1














                              This might be too late to answer but surely will help others.



                              Please use below cmd to achieve long press.



                              adb shell input keyevent 5 sleep 5






                              share|improve this answer



















                              • 4





                                This does not work.

                                – arka.b
                                Aug 27 '15 at 6:21











                              • Please share problem statement I'll provide solution.

                                – Arpana
                                Aug 27 '15 at 11:46






                              • 1





                                Error: Invalid arguments for command: keyevent

                                – Андрій Ковальчук
                                Feb 22 '16 at 14:21











                              • share your adb command

                                – Arpana
                                Feb 23 '16 at 5:26











                              • adb shell input keyevent 5 ; sleep 5

                                – DarkXDroid
                                Mar 31 '17 at 8:38
















                              -1














                              This might be too late to answer but surely will help others.



                              Please use below cmd to achieve long press.



                              adb shell input keyevent 5 sleep 5






                              share|improve this answer



















                              • 4





                                This does not work.

                                – arka.b
                                Aug 27 '15 at 6:21











                              • Please share problem statement I'll provide solution.

                                – Arpana
                                Aug 27 '15 at 11:46






                              • 1





                                Error: Invalid arguments for command: keyevent

                                – Андрій Ковальчук
                                Feb 22 '16 at 14:21











                              • share your adb command

                                – Arpana
                                Feb 23 '16 at 5:26











                              • adb shell input keyevent 5 ; sleep 5

                                – DarkXDroid
                                Mar 31 '17 at 8:38














                              -1












                              -1








                              -1







                              This might be too late to answer but surely will help others.



                              Please use below cmd to achieve long press.



                              adb shell input keyevent 5 sleep 5






                              share|improve this answer













                              This might be too late to answer but surely will help others.



                              Please use below cmd to achieve long press.



                              adb shell input keyevent 5 sleep 5







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered May 5 '15 at 5:41









                              ArpanaArpana

                              369311




                              369311








                              • 4





                                This does not work.

                                – arka.b
                                Aug 27 '15 at 6:21











                              • Please share problem statement I'll provide solution.

                                – Arpana
                                Aug 27 '15 at 11:46






                              • 1





                                Error: Invalid arguments for command: keyevent

                                – Андрій Ковальчук
                                Feb 22 '16 at 14:21











                              • share your adb command

                                – Arpana
                                Feb 23 '16 at 5:26











                              • adb shell input keyevent 5 ; sleep 5

                                – DarkXDroid
                                Mar 31 '17 at 8:38














                              • 4





                                This does not work.

                                – arka.b
                                Aug 27 '15 at 6:21











                              • Please share problem statement I'll provide solution.

                                – Arpana
                                Aug 27 '15 at 11:46






                              • 1





                                Error: Invalid arguments for command: keyevent

                                – Андрій Ковальчук
                                Feb 22 '16 at 14:21











                              • share your adb command

                                – Arpana
                                Feb 23 '16 at 5:26











                              • adb shell input keyevent 5 ; sleep 5

                                – DarkXDroid
                                Mar 31 '17 at 8:38








                              4




                              4





                              This does not work.

                              – arka.b
                              Aug 27 '15 at 6:21





                              This does not work.

                              – arka.b
                              Aug 27 '15 at 6:21













                              Please share problem statement I'll provide solution.

                              – Arpana
                              Aug 27 '15 at 11:46





                              Please share problem statement I'll provide solution.

                              – Arpana
                              Aug 27 '15 at 11:46




                              1




                              1





                              Error: Invalid arguments for command: keyevent

                              – Андрій Ковальчук
                              Feb 22 '16 at 14:21





                              Error: Invalid arguments for command: keyevent

                              – Андрій Ковальчук
                              Feb 22 '16 at 14:21













                              share your adb command

                              – Arpana
                              Feb 23 '16 at 5:26





                              share your adb command

                              – Arpana
                              Feb 23 '16 at 5:26













                              adb shell input keyevent 5 ; sleep 5

                              – DarkXDroid
                              Mar 31 '17 at 8:38





                              adb shell input keyevent 5 ; sleep 5

                              – DarkXDroid
                              Mar 31 '17 at 8:38


















                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f11142843%2fhow-can-i-use-adb-to-send-a-longpress-key-event%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              這個網誌中的熱門文章

                              Hercules Kyvelos

                              Tangent Lines Diagram Along Smooth Curve

                              Yusuf al-Mu'taman ibn Hud