How to use the rc-util/lib/KeyCode.HOME function in rc-util

To help you get started, we’ve selected a few rc-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github react-component / calendar / tests / RangeCalendar.spec.jsx View on Github external
};

    // 09-03 down 09-10
    keySimulateCheck(keyCode.DOWN, 'Sep', 10);

    // 09-03 left 09-09
    keySimulateCheck(keyCode.LEFT, 'Sep', 9);

    // 09-09 right 09-10
    keySimulateCheck(keyCode.RIGHT, 'Sep', 10);

    // 09-10 right 09-03
    keySimulateCheck(keyCode.UP, 'Sep', 3);

    // 09-10 home 09-01
    keySimulateCheck(keyCode.HOME, 'Sep', 1);

    // 09-10 end 09-30
    keySimulateCheck(keyCode.END, 'Sep', 30);

    // 09-30 page up 08-30
    keySimulateCheck(keyCode.PAGE_UP, 'Aug', 30);

    // 08-30 page down 09-30
    keySimulateCheck(keyCode.PAGE_DOWN, 'Sep', 30);

    keyDown(keyCode.BACKSLASH);
    expect(keyDownEvent).toEqual(1);

    keyDown(keyCode.ENTER);

    expect(onChange.mock.calls[0][0][0].format(format)).toEqual('2000-09-30');
github antvis / x6 / packages / x6-components / src / scrollbar / index.tsx View on Github external
onKeyDown = (e: React.KeyboardEvent) => {
    const keyCode = e.keyCode

    // let focus move off the scrollbar
    if (keyCode === keys.TAB) {
      return
    }

    const { contentSize, containerSize } = this.props
    let distance = this.props.keyboardScrollAmount
    let direction = 0

    if (this.isHorizontal()) {
      switch (keyCode) {
        case keys.HOME:
          direction = -1
          distance = contentSize
          break

        case keys.LEFT:
          direction = -1
          break

        case keys.RIGHT:
          direction = 1
          break

        default:
          return
      }
    } else {
github react-component / calendar / tests / Calendar.spec.jsx View on Github external
it('HOME works', () => {
        const original = calendar.state().value;
        const expected = original.clone().startOf('month');
        calendar.setState({ value: original.add(2, 'day') });

        calendar.simulate('keyDown', {
          keyCode: keyCode.HOME,
        });
        expect(calendar.state().value.date()).toBe(expected.date());
      });
github iuap-design / bee.tinper.org / tinper-bee / bee-datepicker / src / rc-calendar / RangeCalendar.js View on Github external
return;
      case KeyCode.LEFT:
        if (ctrlKey) {
          updateHoverPoint((time) => goTime(time, -1, 'years'));
        } else {
          updateHoverPoint((time) => goTime(time, -1, 'days'));
        }
        return;
      case KeyCode.RIGHT:
        if (ctrlKey) {
          updateHoverPoint((time) => goTime(time, 1, 'years'));
        } else {
          updateHoverPoint((time) => goTime(time, 1, 'days'));
        }
        return;
      case KeyCode.HOME:
        updateHoverPoint((time) => goStartMonth(time));
        return;
      case KeyCode.END:
        updateHoverPoint((time) => goEndMonth(time));
        return;
      case KeyCode.PAGE_DOWN:
        updateHoverPoint((time) => goTime(time, 1, 'month'));
        return;
      case KeyCode.PAGE_UP:
        updateHoverPoint((time) => goTime(time, -1, 'month'));
        return;
      case KeyCode.ENTER: {
        let lastValue;
        if (hoverValue.length === 0) {
          lastValue = updateHoverPoint(time => time);
        } else if (hoverValue.length === 1) {
github react-component / calendar / src / RangeCalendar.tsx View on Github external
return;
      case KeyCode.LEFT:
        if (ctrlKey) {
          updateHoverPoint(time => goTime(time, -1, 'years'));
        } else {
          updateHoverPoint(time => goTime(time, -1, 'days'));
        }
        return;
      case KeyCode.RIGHT:
        if (ctrlKey) {
          updateHoverPoint(time => goTime(time, 1, 'years'));
        } else {
          updateHoverPoint(time => goTime(time, 1, 'days'));
        }
        return;
      case KeyCode.HOME:
        updateHoverPoint(time => goStartMonth(time));
        return;
      case KeyCode.END:
        updateHoverPoint(time => goEndMonth(time));
        return;
      case KeyCode.PAGE_DOWN:
        updateHoverPoint(time => goTime(time, 1, 'month'));
        return;
      case KeyCode.PAGE_UP:
        updateHoverPoint(time => goTime(time, -1, 'month'));
        return;
      case KeyCode.ENTER: {
        let lastValue: Moment;
        if (hoverValue.length === 0) {
          lastValue = updateHoverPoint(time => time);
        } else if (hoverValue.length === 1) {
github react-component / calendar / src / Calendar.jsx View on Github external
if (ctrlKey) {
          this.goTime(-1, 'years');
        } else {
          this.goTime(-1, 'days');
        }
        event.preventDefault();
        return 1;
      case KeyCode.RIGHT:
        if (ctrlKey) {
          this.goTime(1, 'years');
        } else {
          this.goTime(1, 'days');
        }
        event.preventDefault();
        return 1;
      case KeyCode.HOME:
        this.setValue(
          goStartMonth(this.state.value),
        );
        event.preventDefault();
        return 1;
      case KeyCode.END:
        this.setValue(
          goEndMonth(this.state.value),
        );
        event.preventDefault();
        return 1;
      case KeyCode.PAGE_DOWN:
        this.goTime(1, 'month');
        event.preventDefault();
        return 1;
      case KeyCode.PAGE_UP:
github react-component / slider / src / utils.js View on Github external
export function getKeyboardValueMutator(e, vertical, reverse) {
  const increase = 'increase';
  const decrease = 'decrease';
  let  method = increase;
  switch (e.keyCode) {
    case keyCode.UP:
      method = vertical && reverse ? decrease: increase; break;
    case keyCode.RIGHT:
      method = !vertical && reverse ? decrease: increase; break;
    case keyCode.DOWN:
      method = vertical && reverse ? increase: decrease; break;
    case keyCode.LEFT:
      method = !vertical && reverse ? increase: decrease; break;

    case keyCode.END: return (value, props) => props.max;
    case keyCode.HOME: return (value, props) => props.min;
    case keyCode.PAGE_UP: return (value, props) => value + props.step * 2;
    case keyCode.PAGE_DOWN: return (value, props) => value - props.step * 2;

    default: return undefined;
  }
  return (value, props) => calculateNextValue(method, value, props);
}
github priceline / design-system / packages / slider / src / rc-slider / utils.js View on Github external
export function getKeyboardValueMutator(e) {
  switch (e.keyCode) {
    case keyCode.UP:
    case keyCode.RIGHT:
      return (value, props) => calculateNextValue('increase', value, props)

    case keyCode.DOWN:
    case keyCode.LEFT:
      return (value, props) => calculateNextValue('decrease', value, props)

    case keyCode.END:
      return (value, props) => props.max
    case keyCode.HOME:
      return (value, props) => props.min
    case keyCode.PAGE_UP:
      return (value, props) => value + props.step * 2
    case keyCode.PAGE_DOWN:
      return (value, props) => value - props.step * 2

    default:
      return undefined
  }
}
github iuap-design / bee.tinper.org / tinper-bee / bee-datepicker / src / rc-calendar / Calendar.jsx View on Github external
if (ctrlKey) {
          this.goTime(-1, 'years');
        } else {
          this.goTime(-1, 'days');
        }
        event.preventDefault();
        return 1;
      case KeyCode.RIGHT:
        if (ctrlKey) {
          this.goTime(1, 'years');
        } else {
          this.goTime(1, 'days');
        }
        event.preventDefault();
        return 1;
      case KeyCode.HOME:
        this.setValue(
          goStartMonth(this.state.value),
        );
        event.preventDefault();
        return 1;
      case KeyCode.END:
        this.setValue(
          goEndMonth(this.state.value),
        );
        event.preventDefault();
        return 1;
      case KeyCode.PAGE_DOWN:
        this.goTime(1, 'month');
        event.preventDefault();
        return 1;
      case KeyCode.PAGE_UP: