There's also a free app called Karabiner Elements. It can be used for various mappings, including keyboard and mouse.
Get it from: https://pqrs.org/osx/karabiner/
I've been using it successfully since getting a mac.
With this you can add a "Complex Modification" from their site. I found one for back and forward functionality.
Make sure to tick the devices you want to use in the Preference pane of the app.
A manual config would look similar to the partial listing below. This would have to be integrated into the file karabiner.json
in your ~/.config/karabiner
folder.
In this example the buttons 4 and 5 are mapped to Cmd + [ and Cmd + ] respectively.
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
"basic.simultaneous_threshold_milliseconds": 50,
"basic.to_delayed_action_delay_milliseconds": 500,
"basic.to_if_alone_timeout_milliseconds": 1000,
"basic.to_if_held_down_threshold_milliseconds": 500
},
"rules": [
{
"description": "Change button4,5 to back,forward (rev 1)",
"manipulators": [
{
"conditions": [
{
"keyboard_types": [
"ansi",
"iso"
],
"type": "keyboard_type_if"
}
],
"from": {
"modifiers": {
"optional": [
"caps_lock"
]
},
"pointing_button": "button4"
},
"to": [
{
"key_code": "open_bracket",
"modifiers": "left_command"
}
],
"type": "basic"
},
{
"conditions": [
{
"keyboard_types": [
"ansi",
"iso"
],
"type": "keyboard_type_if"
}
],
"from": {
"modifiers": {
"optional": [
"caps_lock"
]
},
"pointing_button": "button5"
},
"to": [
{
"key_code": "close_bracket",
"modifiers": "left_command"
}
],
"type": "basic"
}
]
}
]
},
"devices": [<ommited>],
"name": "your_profile_name",
"selected": true,
"virtual_hid_keyboard": {
"country_code": 0
}
},
]
}