Maybe something like this is what you're looking for?
It gets the itemLink from the item that is currently displayed on the tooltip and gets the itemID from the link.
Lua Code:
local _, itemLink = GameTooltip:GetItem();
if (itemLink) then
local itemID = tonumber(strmatch(itemLink, "item:(%d+):"));
end
To add bindings to the default UI you can use bindings.xml:
https://wowwiki.fandom.com/wiki/Usin...for_your_addon