{
// Alt/Ctrl/Meta+Arrow belong to the browser (Alt/Cmd+Left is Back).
if (effectiveDisabled || readonly || hasModifierKey(event)) return;
readDirection();
if (event.key === "Home" || event.key === "End") {
// Prevent the browser from also scrolling to the top/bottom of the page.
event.preventDefault();
value = event.key === "Home" ? min : max;
dispatch("input", value);
dispatch("change", value);
return;
}
// Left and right move the thumb the way they point, as they do
// on a native range input in RTL.
/** @type {Record} */
const keys = {
ArrowDown: -1,
ArrowLeft: horizontalRtl ? 1 : -1,
ArrowRight: horizontalRtl ? -1 : 1,
ArrowUp: 1,
PageDown: -1,
PageUp: 1,
};
if (keys[event.key]) {
// Prevent the arrow/page keys from also scrolling the page.
event.preventDefault();
const isLargeStep =
event.shiftKey ||
event.key === "PageUp" ||
event.key === "PageDown";
if (snapToMarks && resolvedMarks.length) {
value = stepMarks(
value,
resolvedMarks,
keys[event.key] * (isLargeStep ? stepMultiplier : 1),
);
} else {
const delta =
step *
(isLargeStep ? range / step / stepMultiplier : 1) *
keys[event.key];
value = snapToStep(value + delta, { min, max, step });
}
dispatch("input", value);
dispatch("change", value);
}
}}
>