How to use the keycode-js.KEY_END function in keycode-js

To help you get started, we’ve selected a few keycode-js 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 cerner / terra-core / packages / terra-form-select / src / multiple / Menu.jsx View on Github external
} else if (keyCode === KeyCode.KEY_RETURN && active !== null && MenuUtil.includes(value, active)) {
      event.preventDefault();

      const option = MenuUtil.findByValue(children, active);
      // Handles communicating the case where a regular option is Unselected to screen readers.
      if (visuallyHiddenComponent && visuallyHiddenComponent.current) {
        visuallyHiddenComponent.current.innerHTML = intl.formatMessage({ id: 'Terra.form.select.unselectedText' }, { text: option.props.display });
      }

      if (onDeselect) {
        onDeselect(option.props.value, option);
      }
    } else if (keyCode === KeyCode.KEY_HOME) {
      event.preventDefault();
      this.setState({ active: MenuUtil.findFirst(children) });
    } else if (keyCode === KeyCode.KEY_END) {
      event.preventDefault();
      this.setState({ active: MenuUtil.findLast(children) });
    }
  }
github cerner / terra-core / packages / terra-form-select / src / tag / Menu.jsx View on Github external
} else if (keyCode === KeyCode.KEY_RETURN && active !== null && MenuUtil.includes(value, active)) {
      event.preventDefault();

      const option = MenuUtil.findByValue(children, active);
      // Handles communicating the case where a regular option is Unselected to screen readers.
      if (visuallyHiddenComponent && visuallyHiddenComponent.current) {
        visuallyHiddenComponent.current.innerHTML = intl.formatMessage({ id: 'Terra.form.select.unselectedText' }, { text: option.props.display });
      }

      if (onDeselect) {
        onDeselect(option.props.value, option);
      }
    } else if (keyCode === KeyCode.KEY_HOME) {
      event.preventDefault();
      this.setState({ active: MenuUtil.findFirst(children) });
    } else if (keyCode === KeyCode.KEY_END) {
      event.preventDefault();
      this.setState({ active: MenuUtil.findLast(children) });
    }
  }
github cerner / terra-core / packages / terra-dropdown-button / src / _DropdownList.jsx View on Github external
} else if (keyCode === KeyCode.KEY_DOWN) {
      if (!this.pressed) {
        this.changeFocusState(Util.findNext(this, this.state.focused));
      }
      event.preventDefault();
    } else if (keyCode === KeyCode.KEY_UP) {
      if (!this.pressed) {
        this.changeFocusState(Util.findPrevious(this, this.state.focused));
      }
      event.preventDefault();
    } else if (keyCode === KeyCode.KEY_HOME) {
      if (!this.pressed) {
        this.changeFocusState(0);
      }
      event.preventDefault();
    } else if (keyCode === KeyCode.KEY_END) {
      if (!this.pressed) {
        this.changeFocusState(Util.getChildArray(this).length - 1);
      }
      event.preventDefault();
    } else if (keyCode === KeyCode.KEY_TAB) {
      this.props.requestClose();
      event.preventDefault();
    } else if (keyCode >= 48 && keyCode <= 90) {
      this.searchString = this.searchString.concat(String.fromCharCode(keyCode));
      clearTimeout(this.searchTimeout);
      this.searchTimeout = setTimeout(this.clearSearch, 500);
      let newFocused = Util.findWithStartString(this, this.searchString);

      if (newFocused === -1) {
        newFocused = this.state.focused;
      }
github cerner / terra-core / packages / terra-form-select / src / single / Menu.jsx View on Github external
is added to aria-live container.
        When we shift focus back to select, VoiceOver automatically reads the display text.
        Using aria-hidden on the display does not prevent VO from reading the display text and so it
        results in reading the display text followed by reading the aria-live message which is
        the display text + 'selected'
        */
        if (!SharedUtil.isSafari()) {
          visuallyHiddenComponent.current.innerText = `${option.props.display} ${selectedTxt}`;
        }
      }

      onSelect(option.props.value, option);
    } else if (keyCode === KeyCode.KEY_HOME) {
      event.preventDefault();
      this.setState({ active: MenuUtil.findFirst(children) });
    } else if (keyCode === KeyCode.KEY_END) {
      event.preventDefault();
      this.setState({ active: MenuUtil.findLast(children) });
    } else if (keyCode >= 48 && keyCode <= 90) {
      this.searchString = this.searchString.concat(key);
      clearTimeout(this.searchTimeout);
      this.searchTimeout = setTimeout(this.clearSearch, 500);
      this.setState(prevState => ({ active: MenuUtil.findWithStartString(prevState.children, this.searchString) || active }));
    }
  }
github cerner / terra-core / packages / terra-form-select / src / combobox / Menu.jsx View on Github external
is added to aria-live container.
        When we shift focus back to select, VoiceOver automatically reads the display text.
        Using aria-hidden on the display does not prevent VO from reading the display text and so it
        results in reading the display text followed by reading the aria-live message which is
        the display text + 'selected'
        */
        if (!SharedUtil.isSafari()) {
          this.props.visuallyHiddenComponent.current.innerText = `${option.props.display} ${selectedTxt}`;
        }
      }

      onSelect(option.props.value, option);
    } else if (keyCode === KeyCode.KEY_HOME) {
      event.preventDefault();
      this.setState({ active: MenuUtil.findFirst(children) });
    } else if (keyCode === KeyCode.KEY_END) {
      event.preventDefault();
      this.setState({ active: MenuUtil.findLast(children) });
    }
  }
github cerner / terra-core / packages / terra-form-select / src / search / Menu.jsx View on Github external
Detecting if browser is not Safari before updating aria-live as there is some odd behaivor
        with VoiceOver on desktop, that causes the selected option to be read twice when this is
        is added to aria-live container.
        When we shift focus back to select, VoiceOver automatically reads the display text.
        Using aria-hidden on the display does not prevent VO from reading the display text and so it
        results in reading the display text followed by reading the aria-live message which is
        the display text + 'selected'
        */
      if (!SharedUtil.isSafari()) {
        this.props.visuallyHiddenComponent.current.innerText = `${option.props.display} ${selectedTxt}`;
      }
      onSelect(option.props.value, option);
    } else if (keyCode === KeyCode.KEY_HOME) {
      event.preventDefault();
      this.setState({ active: MenuUtil.findFirst(children) });
    } else if (keyCode === KeyCode.KEY_END) {
      event.preventDefault();
      this.setState({ active: MenuUtil.findLast(children) });
    }
  }