Clicking backbutton would close your viewcontroller which shows the modal.
I guess you don't want that happen, and just close the javascript modal.
Yes you would need to change your native code.
On native backbutton click,
if your modal is open:
close the modal
else:
do default backbutton action.
Below is a detailed explanation.
On native backbutton click # your native code to intercept the back button
if your modal is open:
# there are multiple options here
# first strategy
# let javascript inform native side when it opens/closes popup
# native just needs to check the status he has
# second strategy
# native asks javascript if he has a modal open
# this is a bit tricky because native can't get a return value from javascript
# native asks javascript to tell native if he has a modal open (native->javascript + javasciprt -> native two function calls)
# native checks what javascript just said
close the modal
# this is easy, ask javascript to close it.
I assumed you know how to communicate between javascript & native, if not take a look at http://www.smashingmagazine.com/2013/10/best-of-both-worlds-mixing-html5-native-code/