Well, you could say that there are three branches of electronics: analog, digital, and discrete (sort of between the previous two). For your goals, you mainly need to learn about digital systems.
What you'll mainly be dealing with in terms of digital systems are microcontrollers and other embedded systems. I'd say the main two places to get started with those are the Arduino and Raspberry Pi ecosystems. The first is "more pure microcontroller" and the second is "more advanced embedded systems".
Microcontrollers are mostly programmed in C++ these days (with a few strange people like me using Assembly), and the Arduino ecosystem sort of teaches that. Microcontrollers are usually the most efficient system to make the control electronics for something like a keyboard. Sparkfun and Adafruit are good companies to buy parts to get started from.
Embedded systems like the Raspberry Pi stuff can often run a whole operating system. This is too expensive (power, space, and $) for most keyboard builds, but you may want to learn how to use them for other projects. However, they also make a microcontroller (the Pi Pico) which would be OK and can be programmed in Python.
For advanced computer peripherals, you might need to learn FPGAs. However, that can be a difficult topic to get into by comparison. So maybe leave that for later.
A good way to get started is to buy the parts for, and build, a few Arduino projects. There are specific libraries for making Arduinos emulate a PC keyboard too.
In terms of tools, at first you will just need a breadboard, some resistors, LEDs and jumper wires. Maybe a battery or USB power supply. A multimeter too.
Soon after you will probably want to learn to solder to start making your own standalone devices. You should get a soldering station with temperature control -- some people swear by Hakko, myself I have a cheap-but-good Yihua soldering + hot air rework station.
Next, while Sparkfun and Adafruit are great businesses, they are not cost-effective ways to source a lot of parts. You'll want to learn how to use the part search and ordering functions on Digikey, Mouser, Arrow, and RS Components. Maybe also McMaster-Carr if you do mechanical stuff.
When you have some working designs done, you will probably want to learn KiCAD. It's software for designing circuits, and laying out printed circuit boards (PCBs) to send to a factory to be made professionally. Through the magic of globalization, this is actually pretty affordable! A typical run costs me 20-40$ for 10 units, and takes 16 business days -- although I live in Asia, so it might cost a little more from the USA or Europe.
You'll also maybe want to learn 3D modelling and printing, for designing cases (I struggle with this more than I'd like to admit). TinkerCAD is an OK place to get started, although tools like SolidWorks are certainly more advanced. You don't need to buy a 3D printer unless you want to -- you can just order your designs made online.
Anyway, the results with KiCAD + 3D printing can be really quite good and can last many years of use. They also let you share your design with others, so other people can make it!
Finally, if there's a hackerspace / makerspace in your area, these are great communities of people you can learn from. Definitely check them out. They may have a 3D printer you can use, as well as other tools. Often they teach courses too.
One small note -- getting from "hey neat this works!" to making and selling a product is (sadly) a really big step. So if you one day want to do that, build a network and ask for advice from someone who has gone through it first.