Skip to content

Refactor Keybindings and Set Defaults #501

Open
@danpastori

Description

@danpastori

Discussed in #500

Originally posted by danpastori May 4, 2022

👉 Describe the problem

Allow for default keybindings to be set to control the audio player from the keyboard. It's a pain to set this everytime when 90% of the time the same button is going to perform the same task.

👥 Problem evidence & reach

Anyone wanting to control the audio player from the keyboard

🥰 Describe the "impact" on users?

You won't have to figure out basic key binding support, but maintain the ability to set any function to any key.

🏆 How to solve this problem

Step 1: Refactor the bindings config key to be key_bindings

This will be a breaking change, but makes more sense. Documentation will be provided.

Step 2: Allow for the following configurations for keybindings:

Binding from key id to Amplitude method

{
	key_bindings: [
		{
			key: 39,
			method: 'play'
		}
	]
}

Binding from key id to callback method

{
	key_bindings: [
		{
			key: 39,
			method: function(){
				// run method
			}
		}
	]
}

Binding from key id to custom method defined elsewhere

{
	key_bindings: [
		{
			key: 39,
			method: 'my_custom_method'
		}
	]
}

Default keybindings

{
	key_bindings: {
		default: true
	}
}

💯 How do we validate the problem is solved?

Developers will be able to provide complete custom control from their keyboard to their audio player defined through the key_bindings config key. They will be able to map to an Amplitude method, callback method, custom method, or set just the defaults which will be defined in the documentation.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Ready for Development

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions