Is it possible to combine these two functions?

Is it possible to combine these two functions?

I have a menu that I toggle when a button is clicked, and when you click off of it or on a link inside of it, it then hides. I also have it set up so that the esc key will close it, but I was curious if I could somehow combine them into one? Heres that I have so far.. everything i've tried doesn't seem to work so if someone could point me in the right direction that would be awesome - Thanks!

  1. //Toggle functionality for menu
  2. $(function(){
  3.     var effect = 'slide';
  4.     var options = { direction: 'left'};
  5.     var duration = 500;
  6.     
  7.     //Slide toggle menu
  8.     $('#m').click(function () { 
  9.         $('#mOpt').toggle(effect, options, duration);   
  10.     });
  11.     
  12.     //Slides menu left to hide when clicking on any <section>
  13.     $('section, a[href*="#"]:not([href="#"])').click(function(){ 
  14.         $('#mOpt').hide(effect, options, duration);
  15.     });
  16.     //Slides menu left to hide on key up esc
  17.     $(document).on('keydown',function(e) {
  18.         if (e.keyCode == 27) {
  19.             $('#mOpt').hide(effect, options, duration);
  20.         };
  21.     });
  22. });