it is most likely that there is dirt or something causing the button to stop working or to start working randomly of it own accord. you'd need to remove the back cover to expose the button contacts and give them a good clean, worst case scenario you'd be buying a rear cover button flex cable fpc.
it can be a fiddly job with screws hidden all over the place, there is no guide on iFixit to do this but there are guides for similar models like the D5200.
follow this guide to removing the back cover, once you have the back cover off its a pretty simple job to remove the ribbon cable and clean or replace.
[guide|50939]