Each solution you find online has a different approach to measuring keyword difficulty. Whether you have already chosen the most suitable SEO tool, you have to figure out how exactly it calculates the KD. For example, some platforms take the top 10 pages for the desired keyword and see how many sites link to them. The more links, the higher the keyword difficulty score.
However, many companies and SEO experts state that it is necessary to consider a range of other factors while calculating the KD. These include the number of domain links, domain rating, relevancy, content length, etc. You can use the formulas offered by famous SEO companies and platforms like Ahrefs to calculate the keyword difficulty faster.