• Open System Preferences from the Apple menu
• Click on "Keyboard" and select the "Shortcuts" tab
• Choose “App Shortcuts" from the list on the left, then click the [+] plus icon to add a new shortcut
• Select "Safari" from the Application pull down list, then type "Merge All Windows" as the menu title
• Finally, set the keyboard shortcut to use, we went with Control+Command+W as a variation of the common close windows command
• Click "Add" then go back to Safari, open a few windows, and hit your keyboard shortcut to verify it worked
If the keyboard shortcut didn’t work, you may have chosen a keystroke that conflicts with another function, or you may have not entered the menu title properly. Custom keyboard shortcuts are case sensitive, so be sure to use the proper capitalization and exact spelling.