SAMD51 Interrupt via Button Press

Anyone know how to configure a pin on a SAMD51 like Adafruit's M4 Metro or Feather Express such that it calls a function on a button press?

An example from Adafruit for the nRF52480 called "digital_interrupt_deferred" has something like this. The code looks like this:

pinMode(interruptPin, INPUT_PULLUP);
attachInterrupt(interruptPin, digital_callback, ISR_DEFERRED | CHANGE);

It then calls that function when the pin state changes ... very neato.

Anybody know how to accomplish something similar on a SAMD51 type board?

It might help:

Post here about your Arduino projects, get help - for Adafruit customers!

I believe that attachInterrupt() works similarly on SAMD51 boards.
There's a complication that there are only 16 pin interrupts, shared by more than 16 pins, and only one pin that shares an interrupt will actually generate the interrupt (last one enabled, first one enabled? Not sure.)
But that shouldn't matter for a single button.
I don't think that the SAMD51 has ISR_DEFERRED, though.
It'd look like:

attachInterrupt(interruptPin, digital_callback, CHANGE);

(attachInterrupt is a standard Arduino Core function, though some of the details can change.)

Excellent, thank you everyone:

void setup() {
Serial.begin(9600);
while (!Serial);
delay(50);
attachInterrupt(digitalPinToInterrupt(12), anISR, CHANGE);
}

void loop() {
}

void anISR() {
Serial.println(digitalRead(12));
}