How would I go about making a custom minecraft item that triggers events when it's used?

//ads -- adsterra.com -- native banner
?>
In specific, I'm looking to code a sword that, when used to block, advances the time of day by 4800. Hopefully this can be accomplished with command blocks only, as I'd rather stick to vanilla minecraft.
So far, I've only figured out how to correctly employ custom names and enchantments, so this is all I've got for the command:
/give @p iron_sword 1 0 {display:{Name:"Longdark Blade",Lore:"[Long ago, it was thought that metals","could control the stars themselves...]"}}
Pictures about "How would I go about making a custom minecraft item that triggers events when it's used?"



How to Create Custom Items in Minecraft 1.18
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Andrea Piacquadio, Thirdman, mentatdgt, Andrea Piacquadio