What part of speech is "by" in this sentence?

In sentences like these below, what part of speech or what grammatical function does "by" serve?

  • Open the door BY turning your key.
  • Lift the bucket BY pulling on the rope.

Solution 1:

The Cambridge English Dictionary (online) gives two related definitions of the preposition by which are relevant to your examples. They are: agency (explaining by whom or by what an action is caused - in short, the agent); and method Explaining how and action is accomplished.

You can find the definitions and plenty of examples here: https://dictionary.cambridge.org/dictionary/english/by.

It is possible to argue that these to meanings are to all intents and purposes the same: to express what or who brought something about.