'Long press a custom physical button on android device with appium java

I have a an custom-made phone in which it has a specific SOS button that I need to long press.

I am trying to do key press like this.

   driver.longPressKey(new KeyEvent( AndroidKey.HOME) );

which is working but Custom key code 287. How do I send that? I tried something like this

driver.longPressKey(new KeyEvent( AndroidKey.valueOf("287")) );

but this gives an enum error

Version: java-client: 7.5.1



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source