Camera issue on Nexus 5 and Pixel Phone

My code

  • ((AndroidDriver) driver).pressKeyCode(27);
    or
  • ((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.KEYCODE_CAMERA);

is not working to take a picture in the app. ( I only have it on the Nexus 5 and Pixel Phone)

When I try cmd “adb shell input keyevent 27” when i am in the app, also no reaction. When i try the same cmd in the camera app, it does take a picture.

I do have the same when i try the cmd when i am in Facebook app and try to take a picture.
Someone with experience with this ?

UPDATE: I also have it on Nexus 6p.