I have tried the most popular applications but no default shortcuts. For instance pressing the button long time could be one. I am using Samsung Galaxy 4 and Android 5.0.1.
Is there any shortcut for a better flashlight in Android?
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It only takes a minute to sign up.Sign up to join this community
Setup all the apps and launch Tasker
Profile 1: Event → Plugin → AutoInput → Key → Configuration
Task for Profile 1: (Actions):
Profile 2: Event → Plugin → AutoInput → Key → Configuration
Task for Profile 2: (Action): Variables → Variable Set:
The explanation for the instructions can be found at the bottom of my answer for Prevent Accidental Reboots when holding down the power button.
As for the duration of long-press, the minimum I could satisfactorily test was one second (Wait action manages it). If your device is fast enough, you may have some good results for milliseconds. Configure Wait as per your wish.
Also, alike my other answer, the long-press for screen off would work if there involves a traditional hardware button (like Power button) which can be pressed and not simply touched.
This is as far as I understood your question. You simply want to attach an action to long-press of Home key. This action, at the moment, is about activating the flashlight.
Since you can opt for root, you can also consider opting for Xposed Framework (the installer here may not work for Samsung devices running Lollipop. You would need to visit XDA forum).
Optionally, read my answer for Page up and page down in web pages and elsewhere to become familiar with the interface of Xposed Additions.
All you've to do is:
Install and enable Xposed Addtions module. Launch it.
Go to Buttons → optionally configure Long press delay → Add new Key and configure it.
Select the entry for your key → Add new Condition → Screen On → Screen On → activate Long Press → Long Press.
Replace Screen On with Screen Off, if required. Screen Off would work only for hardware buttons, such as Power button (buttons which you can actually press).
Either choose Torch or go to Shortcut → TeslaLED Toggle.