In most countries, Apple offer a one-year limited warranty for its products - although there are a few exceptions. For example, within member states of the European Union, the manufacturer’s warranty extends to two years; within the UK, a claim for manufacturing defects can, in some circumstances, be made up to six years from purchase.
If eligible for a warranty claim, you would be best advised to initially seek assistance from the retailer at which you purchased your keyboard. Otherwise, you might visit the Genius Bar at your local Apple Store or Apple Authorised Service Provider (AASP), where the technicians will be able to test and assess your Keyboard - and you’ll be able to explore your available options.
Genius Bar Reservation and Apple Support Options - Apple